/// <summary> /// 编辑库存仓库 /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="is_default"></param> /// <param name="is_active"></param> /// <param name="userId"></param> /// <returns></returns> public bool EditLocation(long id, string name, bool is_default, bool is_active, long userId) { ivt_warehouse lct = dal.FindById(id); if (lct == null) { return(false); } ivt_warehouse lctOld = dal.FindById(id); lct.name = name; lct.is_active = (sbyte)(is_active ? 1 : 0); lct.is_default = (sbyte)(is_default ? 1 : 0); lct.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lct.update_user_id = userId; if (lct.resource_id != null) { lct.is_default = 0; } if (lctOld.is_default == 0 && lct.is_default == 1) // 只能设置一个默认仓库 { string sql = "update ivt_warehouse set is_default=0 where delete_time=0"; dal.ExecuteSQL(sql); } dal.Update(lct); OperLogBLL.OperLogUpdate <ivt_warehouse>(lct, lctOld, lct.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_LOCATION, "编辑库存仓库"); return(true); }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"]; if (IsPostBack) { if (string.IsNullOrEmpty(id)) { bll.AddLocation(name.Text, is_default.Checked, is_active.Checked, LoginUserId); } else { bll.EditLocation(Convert.ToInt64(id), name.Text, is_default.Checked, is_active.Checked, LoginUserId); } Response.Write("<script>window.close();self.opener.location.reload();</script>"); Response.End(); } else { if (string.IsNullOrEmpty(id)) { is_active.Checked = true; } else { location = bll.GetLocation(Convert.ToInt64(id)); if (location == null) { Response.End(); return; } if (location.resource_id == null) { is_default.Checked = (location.is_default == 1); } else { is_default.Enabled = false; } is_active.Checked = location.is_active == 1; name.Text = location.name; } } }
/// <summary> /// 新增库存仓库 /// </summary> /// <param name="name"></param> /// <param name="is_default"></param> /// <param name="is_active"></param> /// <param name="userId"></param> /// <returns></returns> public bool AddLocation(string name, bool is_default, bool is_active, long userId) { ivt_warehouse lct = new ivt_warehouse(); lct.name = name; lct.is_active = (sbyte)(is_active ? 1 : 0); lct.is_default = (sbyte)(is_default ? 1 : 0); lct.id = dal.GetNextIdCom(); lct.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lct.update_time = lct.create_time; lct.create_user_id = userId; lct.update_user_id = userId; if (lct.is_default == 1) // 只能设置一个默认仓库 { string sql = "update ivt_warehouse set is_default=0 where delete_time=0"; dal.ExecuteSQL(sql); } dal.Insert(lct); OperLogBLL.OperLogAdd <ivt_warehouse>(lct, lct.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_LOCATION, "新增库存仓库"); return(true); }