/// <summary> /// 新增 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static bool Insert(Model.T_Bllb_Storage_tbs obj) { string strSql = string.Format(@"INSERT INTO T_Bllb_Storage_tbs(Storage_SN,Storage_Name,Storage_Type,Step,Respons_Person) VALUES('{0}','{1}','{2}','{3}','{4}')", obj.Storage_SN, obj.Storage_Name, obj.Storage_Type, obj.Step, obj.Respons_Person); return(CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql)); }
/// <summary> /// 修改 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static bool Update(Model.T_Bllb_Storage_tbs obj) { string strSql = string.Format(@"UPDATE T_Bllb_Storage_tbs SET Storage_Name='{1}',Storage_Type='{2}',Step='{3}',Respons_Person='{4}' WHERE Storage_SN='{0}'", obj.Storage_SN, obj.Storage_Name, obj.Storage_Type, obj.Step, obj.Respons_Person); return(CIT.Wcf.Utils.NMS.ExecTransql(PubUtils.uContext, strSql)); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { ShowMsg(string.Empty, true); //dgv_Container.EndEdit(); #region 校验 if (_opreateFlag == "1")//新增 { if (txt_StorageSN.Text.Trim() == string.Empty) { ShowMsg(lbl_SN.Text + "不能为空", false); return; } else if (txt_StorageName.Text.Trim() == string.Empty) { ShowMsg(lbl_Name.Text + "不能为空", false); return; } DataRow[] dr = _dt_storage.Select(string.Format("Storage_SN='{0}' OR Area_SN='{0}' OR Location_SN='{0}'", txt_StorageSN.Text.Trim())); if (dr.Length > 0) { ShowMsg("储位SN已存在", false); return; } dr = _dt_storage.Select(string.Format("Storage_Name='{0}' OR Area_Name='{0}' OR Location_Name='{0}'", txt_StorageName.Text.Trim())); if (dr.Length > 0) { ShowMsg("储位已存在", false); return; } } else if (_opreateFlag == "2")//编辑 { if (txt_StorageName.Text.Trim() == string.Empty) { ShowMsg(lbl_Name.Text + "不能为空", false); return; } DataRow[] dr = _dt_storage.Select(string.Format("Storage_Name='{0}' OR Area_Name='{0}' OR Location_Name='{0}'", txt_StorageName.Text.Trim() /*, txt_StorageSN.Text.Trim()*/)); if (dr.Length > 0) { if (dr[0]["Storage_SN"].ToString() != txt_StorageSN.Text.Trim() & dr[0]["Area_SN"].ToString() != txt_StorageSN.Text.Trim() & dr[0]["Location_SN"].ToString() != txt_StorageSN.Text.Trim()) { ShowMsg(lbl_Name.Text + "已存在", false); return; } } } #region MyRegion //if (_dt_container != null) //{ // //获取库位现在存放的容器数量及类型 // DataTable dt_LocationContainer = Bll_Bllb_StorageLocation_tbsl.GetListOfLocationContainer(txt_StorageSN.Text.Trim()); // foreach (DataRow dr in _dt_container.Rows) // { // int res = 1; // //if (int.TryParse(dr[QTY.Name].ToString(), out res)) // //{ // // if (res == 0) // // { // // ShowMsg("请输入大于0的整数", false); // // return; // // } // //} // //else // //{ // // ShowMsg("请输入大于0的整数", false); // // return; // //} // if (dt_LocationContainer.Rows.Count > 0) // { // if (dr["flag"].ToString() == "3")//删除库位容器信息 // { // if (dt_LocationContainer.Rows[0]["Container_Type"].ToString() == dr["DICT_CODE"].ToString()) // { // ShowMsg(string.Format("库位上有[{0}]不能进行取消", dt_LocationContainer.Rows[0]["DICT_VALUE"]), false); // return; // } // } // else if (dr["flag"].ToString() == "4")//修改库位容器信息 // { // int Container_Qty = int.Parse(dt_LocationContainer.Rows[0]["Container_Qty"].ToString()); // //if (Container_Qty > int.Parse(dr[QTY.Name].ToString())) // //{ // // ShowMsg(string.Format("库位上有[{0}]数量{1}", dt_LocationContainer.Rows[0]["DICT_VALUE"], Container_Qty), false); // // return; // //} // } // } // } //} #endregion if (cbo_Type.SelectedValue.ToString() == "1")//仓库操作 { if (string.IsNullOrEmpty(cbo_Person.Text.Trim())) { ShowMsg("仓库负责人必填", false); return; } try { string sqlCheckUser = string.Format("select * from SysDatUser where UserID='{0}'", cbo_Person.Text.Trim().Substring(cbo_Person.Text.IndexOf('@') + 1)); if (CIT.Wcf.Utils.NMS.QueryDataTable(CIT.MES.PubUtils.uContext, sqlCheckUser).Rows.Count == 0) { ShowMsg("仓库负责人不存在", false); return; } } catch (Exception) { ShowMsg("仓库负责人不存在", false); return; } } #endregion #region 保存数据 //保存数据 if (cbo_Type.SelectedValue.ToString() == "1")//仓库 { #region 仓库数据操作 Model.T_Bllb_Storage_tbs tbs = new Model.T_Bllb_Storage_tbs(); tbs.Storage_SN = txt_StorageSN.Text.Trim(); tbs.Storage_Name = txt_StorageName.Text.Trim(); tbs.Storage_Type = cbo_ParentStorage.SelectedValue.ToString(); tbs.Respons_Person = cbo_Person.Text.Trim().Substring(cbo_Person.Text.Trim().IndexOf('@') + 1); //tbs.Step = cbo_Step.SelectedValue.ToString(); if (_opreateFlag == "1")//新增 { BLL.Bll_Bllb_Storage_tbs.Insert(tbs); } else if (_opreateFlag == "2")//修改 { BLL.Bll_Bllb_Storage_tbs.Update(tbs); } #endregion } else if (cbo_Type.SelectedValue.ToString() == "2")//库区 { #region 库区数据操作 Model.T_Bllb_StorageArea_tbsa tbsa = new Model.T_Bllb_StorageArea_tbsa(); tbsa.Area_SN = txt_StorageSN.Text.Trim(); tbsa.Area_Name = txt_StorageName.Text.Trim(); tbsa.Storage_SN = cbo_ParentStorage.SelectedValue.ToString(); if (_opreateFlag == "1")//新增 { BLL.Bll_Bllb_StorageArea_tbsa.Insert(tbsa); } else if (_opreateFlag == "2")//修改 { BLL.Bll_Bllb_StorageArea_tbsa.Update(tbsa); } #endregion } else if (cbo_Type.SelectedValue.ToString() == "3")//库位 { #region 库位数据操作 Model.T_Bllb_StorageLocation_tbsl tbsl = new Model.T_Bllb_StorageLocation_tbsl(); tbsl.Location_SN = txt_StorageSN.Text.Trim(); tbsl.Location_Name = txt_StorageName.Text.Trim(); tbsl.Area_SN = cbo_ParentStorage.SelectedValue.ToString(); tbsl.Enable_Flag = chk_Enable_Flag.Checked ? "Y" : "N"; if (_opreateFlag == "1")//新增 { BLL.Bll_Bllb_StorageLocation_tbsl.Insert(tbsl); } else if (_opreateFlag == "2")//修改 { BLL.Bll_Bllb_StorageLocation_tbsl.Update(tbsl); } #endregion #region 库位容器信息 //foreach (DataRow dr in _dt_container.Rows) //{ // Model.T_Bllb_LocationContainer_tblc obj = new Model.T_Bllb_LocationContainer_tblc(); // obj.Location_SN = txt_StorageSN.Text.Trim(); // obj.Container_Type = dr["DICT_CODE"].ToString(); // obj.QTY = SqlInput.ChangeNullToInt(dr["QTY"], 1); // if (dr["flag"].ToString() == "2")//新增库位容器信息 // { // BLL.Bll_Bllb_LocationContainer_tblc.Insert(obj); // } // else if (dr["flag"].ToString() == "3")//删除库位容器信息 // { // BLL.Bll_Bllb_LocationContainer_tblc.Delete(obj); // } // else if (dr["flag"].ToString() == "4")//修改库位容器信息 // { // BLL.Bll_Bllb_LocationContainer_tblc.Update(obj); // } //} #endregion } #endregion EnableControl(false); cbo_Type.Enabled = false; cbo_ParentStorage.Enabled = false; txt_StorageName.ReadOnly = true; txt_StorageSN.ReadOnly = true; //checkId.ReadOnly = true; //QTY.ReadOnly = true; tv_Storage.Enabled = true; chk_Enable_Flag.Enabled = false; InitTreeData();//重新加载数据 tv_Storage.Refresh(); ShowMsg("保存成功", true); }