添加:

         /// <summary>
/// 等待乙方做出回应 A
/// </summary>
private void button2_Click_1(object sender, EventArgs e)
{
//使用NHibernate,进行存储
Chinfo c = new Chinfo(); c.CtinfoId = ID;
c.Goodsinfo = "白玉手镯";
c.Buyersinfo = "甲方";
c.Sellerinfo = "乙方";
c.Infocreatetime = DateTime.Now;//字段Infocreatetime是DateTime类型,所以此处不能ToString.
c.Currentgoodsstate = "A";
c.Goodsflow = "";
c.Goodsflownowtime = DateTime.Now.ToString();
c.CourierId = ""; try
{
NHelper.Session().Save(c);
NHelper.Trans().Commit();
MessageBox.Show("保存成功!", "提示");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示");
} this.btn_A.Enabled = false;//禁用A
this.btn_B.Enabled = true;//开启B
this.btn_C.Enabled = true;//开启C
}

修改:

         /// <summary>
/// 乙方已同意请求 等待公司做出回应 B 1100000
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
try
{
IQuery query = NHelper.Session().CreateQuery("from Chinfo c where c.CtinfoId = ?"); query.SetParameter(, ID); IList<Chinfo> list = query.List<Chinfo>(); list[].Currentgoodsstate = "B";
list[].Goodsflow = "";
list[].Goodsflownowtime = list[].Goodsflownowtime + "-" + DateTime.Now.ToString(); NHelper.Session().Update(list[]); NHelper.Trans().Commit(); MessageBox.Show("修改成功!", "提示");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示");
} this.btn_B.Enabled = false;//禁用B
this.btn_C.Enabled = false;//禁用C
this.btn_D.Enabled = true;//开启D
this.btn_E.Enabled = true;//开启E
}

NHelper.cs代码:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NHibernate;
using NHibernate.Cfg; namespace Changing
{
public static class NHelper
{
//变量声明
static ISession session = null;
static ISessionFactory factory = null;
static ITransaction trans = null; //读取配置文件
static Configuration cfg = new Configuration().Configure(@"Config/NHibernate.cfg.xml"); /// <summary>
/// 创建Session工厂
/// </summary>
/// <returns></returns>
public static ISessionFactory Factory()
{
return factory = cfg.BuildSessionFactory();
} /// <summary>
/// 创建Session
/// </summary>
/// <returns></returns>
public static ISession Session()
{
return session = Factory().OpenSession();
} /// <summary>
/// 创建事务
/// </summary>
/// <returns></returns>
public static ITransaction Trans()
{
trans = session.BeginTransaction(); return trans;
}
}
}

NHibernate - HQL - 添加和更改的更多相关文章

  1. hibernate HQL添加语句

    1.Hibernate HQL添加语句 save();方法使用HQL语句来完成插入操作是不能实现的,不管你使用insert into....values...还是insert into.....sel ...

  2. [NHibernate]HQL查询

    目录 写在前面 文档与系列文章 查询的几种方式 HQL查询 一个例子 总结 写在前面 上篇文章介绍了nhibernate在项目中的基本配置,包括数据库连接字符串的设置,映射文件的配置及需注意的地方,这 ...

  3. Hibernate之HQL添加过滤器查询的用法

    HQL查询过程中支持添加过滤器.使用步骤是这样的: 首先在要查询的实体对象的映射中使用<filter-def>标签配置过滤器,并在相对应的<class>标签中添加对应的< ...

  4. 动态添加和更改F7编辑器(div和editGrid列)

    //更改列编辑器 waf("#editGrid").wafGrid("setColumnConfig", "settlementType", ...

  5. NHibernate -- HQL

    使用NHibernate中的HQL来查询数据. 代码: /// <summary> /// 查找事件 /// </summary> private void btn_Selec ...

  6. Nhibernate HQL 匿名类(严格说是map的使用以及构造函数的使用

    1.map的使用 var hql=string.Format(@"select new map( tc.LimitIndexType as LimitIndexType, tc.LimitS ...

  7. [NHibernate]一对多关系(级联删除,级联添加)

    目录 写在前面 文档与系列文章 一对多关系 一个例子 级联删除 级联保存 总结 写在前面 在前面的文章中,我们只使用了一个Customer类进行举例,而在客户.订单.产品中它们的关系,咱们并没有涉及, ...

  8. NHibernate系列文章二十二:NHibernate查询之HQL查询(附程序下载)

    摘要 NHibernate提供了多种查询方式,最早的HQL语言查询.Criteria查询和SQL Query,到NHibernate 3.0的Linq NHibernate,NHIbernate 4. ...

  9. [NHibernate]并发控制

    目录 写在前面 文档与系列文章 并发控制 乐观并发控制(Optimistic Concurrency) 一个例子 悲观并发控制(Pessimistic Concurrency) 总结 写在前面 上篇文 ...

随机推荐

  1. web.xml 的加载顺序

    context-param -> listener -> filter -> servlet

  2. DEDE里有个编码问题,不支持PHP5.4及以上版本!

    公司新配置服务器,没有PHP环境,下载了个PHP5.5.25,配置完毕后,从另外一个服务器转移了一个DEDECMS做的网站,安装后,进入后台,恢复数据发现参数设置里的文本框,只要是中文信息,没有显示, ...

  3. python 中函数参数传递形式

    python中函数参数的传递是通过赋值来传递的.函数参数的使用又有俩个方面值得注意:1.函数参数是如何定义的 2.在调用函数的过程中参数是如何被解析 先看第一个问题,在python中函数参数的定义主要 ...

  4. 如何提高banner设计含量--网上的一篇文章--感悟

    "修改": 本质上是改什么?改大小?图片?文字?颜色? 老板说:修改本质上是提高“设计含量”.检测一个作品设计含量的高低,可以将作品中每一个设计元素进行分析,看它的“属性”与“操作 ...

  5. 机器学习笔记(三)- from Andrew Ng的教学视频

    week four: Non-linear hypotheses:Neural Networks -->x1 and x2 x1 XNOR x2 ->a1->x1 and x2;a2 ...

  6. USACO Ski Course Design 暴力

    从Min到Max范围内暴力一下即可. /* ID: wushuai2 PROG: skidesign LANG: C++ */ //#pragma comment(linker, "/STA ...

  7. ZOJ2849 优先队列BFS

    Attack of Panda Virus Time Limit: 3 Seconds      Memory Limit: 32768 KB In recent months, a computer ...

  8. js Function 加不加new 详解

    以下来自:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new The new operato ...

  9. JavaScript自调用匿名函数

    Self-Invoking Anonymous Function,即自调用匿名函数.顾名思义,该函数没有名称,不同的是,该函数定义后立即被调用.该函数的作用是在应用中初始化或做一次性工作. 普通匿名函 ...

  10. 提高mysql查询效率的六种方法

    1,表设计一定要优化,冗余数据最少,少用连接查询.如果在实际应用中,使用了极其复杂的连接,子查询,则数据表的设计得要重新考虑了. 2,尽量用char而不是varchar,因为固定长度得string用起 ...