protected void Page_Load(object sender, EventArgs e) { var count = Code.MemberManage.Instance.Count(b => b.Id > 0); if (count == 0) { var m = new Code.Member() { Name = "hubro" }; int n = Code.MemberManage.Instance.Add(m); var c = new CRL.ParameCollection(); c["UserId"] = n; Code.ProductDataManage.Instance.Update(b => b.Id > 0, c); } }
protected void Button2_Click(object sender, EventArgs e) { //创建分页存储过程sp_page.sql int page = 1; int pageSize = 15; int count; CRL.ParameCollection c = new CRL.ParameCollection(); string where = " InterFaceUser='******'";//按标准 SQL 进行拼接 c.SetQueryCondition(where); c.SetQueryPageIndex((int)page); c.SetQueryPageSize(pageSize); var list = Code.ProductDataManage.Instance.QueryListByPage(c, out count); }
protected void Button1_Click(object sender, EventArgs e) { //要更新属性集合 CRL.ParameCollection c = new CRL.ParameCollection(); c["ProductName"] = "product1"; Code.ProductDataManage.Instance.Update(b => b.Id == 4, c); //按对象差异更新 var p = new Code.ProductData() { Id = 4 }; //手动修改值时,指定修改属性以在Update时识别,分以下几种形式 p.Change(b => b.BarCode);//表示值被更改了 p.Change(b => b.BarCode,"123");//通过参数赋值 p.Change(b => b.BarCode == "123");//通过表达式赋值 Code.ProductDataManage.Instance.Update(b => b.Id == 4, p);//指定查询更新 Code.ProductDataManage.Instance.Update(p);//按主键更新,主键值是必须的 }
public ActionResult Detail(CRL.Package.RoleAuthorize.Employee u) { CRL.ParameCollection c = new CRL.ParameCollection(); c["Name"] = u.Name; //c["AccountNo"] = u.Name; c["Mobile"] = u.Mobile; c["qq"] = u.QQ; c["Email"] = u.Email; c["Birthday"] = u.Birthday; c["Sex"] = u.Sex; c["IdentityNo"] = u.IdentityNo; c["Address"] = u.Address; c["RegisterIp"] = u.RegisterIp; c["Department"] = u.Department; CRL.Package.RoleAuthorize.EmployeeBusiness.Instance.Update(b => b.Id == u.Id, c); CRL.Package.RoleAuthorize.AccessControlBusiness.Instance.Delete(b => b.Role == u.Id && b.RoleType == CRL.Package.RoleAuthorize.RoleType.用户); //return Redirect("/Employee/"); return AutoBackResult("操作成功", Request.UrlReferrer.ToString()); }
public static void TestUpdate() { var instance = Code.ProductDataManage.Instance; #region 更新 //要更新属性集合 CRL.ParameCollection c = new CRL.ParameCollection(); c["ProductName"] = "product1"; Code.ProductDataManage.Instance.Update(b => b.Id == 4, c); //按对象差异更新 var p = new Code.ProductData() { Id = 4 }; //手动修改值时,指定修改属性以在Update时识别,分以下几种形式 p.Change(b => b.BarCode);//表示值被更改了 p.Change(b => b.BarCode, "123");//通过参数赋值 p.Change(b => b.BarCode == "123");//通过表达式赋值 Code.ProductDataManage.Instance.Update(b => b.Id == 4, p);//指定查询更新 p = Code.ProductDataManage.Instance.QueryItem(b => b.Id > 0); p.UserId += 1; Code.ProductDataManage.Instance.Update(p);//按主键更新,主键值是必须的 #endregion #region 缓存更新 var item = Code.ProductDataManage.Instance.QueryItemFromCache(1); var guid = Guid.NewGuid().ToString().Substring(0,8); item.Change(b => b.SupplierName, guid); Code.ProductDataManage.Instance.Update(item); item = Code.ProductDataManage.Instance.QueryItemFromCache(1); var item2 = Code.ProductDataManage.Instance.QueryItem(1); var a = item.SupplierName == item2.SupplierName && item.SupplierName == guid; if (!a) { throw new Exception("更新缓存失败"); } #endregion #region 事务 string error; item = Code.ProductDataManage.Instance.QueryItem(1); var result = Code.ProductDataManage.Instance.PackageTrans((out string ex) => { ex = ""; var product = new ProductData(); product.BarCode = "sdfsdf"; product.Number = 10; ProductDataManage.Instance.Add(product); return false; }, out error); if (result) { throw new Exception("事务未回滚"); } #endregion }
public ActionResult Update(CRL.Package.RoleAuthorize.Employee u) { CRL.ParameCollection c = new CRL.ParameCollection(); if (!string.IsNullOrEmpty(u.PassWord)) { c["PassWord"] = CRL.Package.RoleAuthorize.EmployeeBusiness.Instance.EncryptPass(u.PassWord); } c["Locked"] = u.Locked; c["Role"] = u.Role; c["Department"] = u.Department; CRL.Package.RoleAuthorize.EmployeeBusiness.Instance.Update(b => b.Id == u.Id, c); return Redirect(Request.UrlReferrer.ToString()); return AutoBackResult("操作成功", Request.UrlReferrer.ToString()); }