/// <summary>
 /// 删除计量单位
 /// </summary>
 private void DeleteUnit(HttpContext context)
 {
     //需要一个实体对象参数
     //1,创建要删除的对象
     Model.base_Unit ma = new Model.base_Unit()
     {
         ID = int.Parse(context.Request["ID"] + ""),//仓库ID
     };
     //2,将对象添加到EF管理容器中
     db.base_Unit.Attach(ma);
     //3,修改对象的包装类对象标识为删除状态
     db.base_Unit.Remove(ma);
     //4,更新到数据库
     int num = db.SaveChanges();
     context.Response.Write("{\"d\":" + num + "}");
 }
Esempio n. 2
0
 /// <summary>
 /// 变价计量单位
 /// </summary>
 private void EditUnit(HttpContext context)
 {
     Model.base_Unit unit = new Model.base_Unit()
     {
         ID = int.Parse(context.Request["ID"] + ""),//原料属性ID
         UnitName = context.Request["UnitName"] + "",
         Status = 1,//状态
         LastUpdateBy = UserInfo.UserName,//编辑人
         LastUpdateTime = DateTime.Now//编辑时间
     };
     //先将实体附加到实体上下文中
     db.base_Unit.Attach(unit);
     //手动修改实体的状态
     db.Entry(unit).State = EntityState.Modified;
     int num = db.SaveChanges();
     context.Response.Write("{\"d\":" + num + "}");
 }
Esempio n. 3
0
 /// <summary>
 /// 添加计量单位
 /// </summary>
 private void AddUnit(HttpContext context)
 {
     Model.base_Unit unit = new Model.base_Unit()
     {
         UnitName = context.Request["UnitName"] + "",//物料属性
         Status = 1,//状态
         AddBy = UserInfo.UserName,//添加人
         AddTime = DateTime.Now//添加时间
     };
     db.base_Unit.Add(unit);
     int num = db.SaveChanges();
     context.Response.Write("{\"d\":" + num + "}");
 }