添加:

         /// <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. System.Web Namespce

    System.Web概述: System.Web是.NET中web应用开发的一个基础类库,定义浏览器与服务器之间的所有操作方法,包括请求输入流(HttpRequest).输出流(HttpRespons ...

  2. elk 索引

    zjtest7-redis:/usr/local/logstash-2.3.4/config# cat logstash_agent.conf input { file { type => &q ...

  3. HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...

  4. Swift - 2 (?和!、结构体、类、协议、扩展、闭包)

    1> 可选类型(?)和强制解包(!) 在swift中,可选类型(?) 其根源是一个 枚举型,里面有 None 和 Some 两种类型.其实所谓的 nil 就是 Optional.None , 非 ...

  5. leetcode_question_64 Minimum Path Sum

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  6. Cocos2d-x 创建自己定义项目模板

    你是否以前为cocos方便高速开发而兴奋,你是否以前为各种工具的便利开发而感动,但如今的你是否为每次创建一个新的项目都是HelloWorldScene而苦恼? 好吧,事实上我也感觉到了,每次创建一个项 ...

  7. ViewPager+Fragment实现支持左右滑动的Tab

    主要思想:顶部标题栏top.xml,中间ViewPager(4个Fragment),底部导航 top.xml和bottom.xml在我之前的两个随笔里有,此处不再赘述. activity_main.x ...

  8. 由zImage生成uImage

    一.手动使用mkimage命令 mkimage -A arm -O linux -T kernel -C none -a 30007fc0 -e 30007fc0 -n uImage   -d /wo ...

  9. [POJ 2588]--Snakes(并查集)

    题目链接:http://poj.org/problem?id=2588 Snakes Time Limit: 1000MS   Memory Limit: 65536K   Description B ...

  10. MYSQL 备份用户权限

    MYSQL 备份用户权限 datadbblack 192.168.1.10 是 SELECT, RELOAD, SHOW DATABASES, LOCK TABLES  否 权限列表 1.Select ...