| | |
| | | private bool Save() |
| | | { |
| | | //判断权限 |
| | | if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) |
| | | { |
| | | return false; |
| | | } |
| | | //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName)) |
| | | //{ |
| | | // return false; |
| | | //} |
| | | // |
| | | if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_AddNew) |
| | | { |
| | | if (oDept.AddNew()) |
| | | { |
| | | Init(); |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | //if (oDept.AddNew()) |
| | | //{ |
| | | // Init(); |
| | | //} |
| | | //else |
| | | //{ |
| | | // return false; |
| | | //} |
| | | Display(); |
| | | } |
| | | if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_Modify) |
| | |
| | | |
| | | private bool AllowSave() |
| | | { |
| | | if (txtHNumber.Text.Trim() == "") |
| | | { |
| | | MessageBox.Show("代码不能为空!", "提示"); |
| | | return false; |
| | | } |
| | | if (txtHName.Text.Trim() == "") |
| | | { |
| | | MessageBox.Show("名称不能为空!", "提示"); |
| | | return false; |
| | | } |
| | | //if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0) |
| | | //if (txtHNumber.Text.Trim() == "") |
| | | //{ |
| | | // MessageBox.Show("负责人不能为空!", "提示"); |
| | | // MessageBox.Show("代码不能为空!", "提示"); |
| | | // return false; |
| | | //} |
| | | //审核代码是否合理 |
| | | if (!DBUtility.ClsPub.AllowNumber(txtHNumber.Text.Trim())) |
| | | { |
| | | MessageBox.Show("代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示"); |
| | | return false; |
| | | } |
| | | //if (txtHName.Text.Trim() == "") |
| | | //{ |
| | | // MessageBox.Show("名称不能为空!", "提示"); |
| | | // return false; |
| | | //} |
| | | ////if (DBUtility.ClsPub.isLong(txtHEmpID.Tag) == 0) |
| | | ////{ |
| | | //// MessageBox.Show("负责人不能为空!", "提示"); |
| | | //// return false; |
| | | ////} |
| | | ////审核代码是否合理 |
| | | //if (!DBUtility.ClsPub.AllowNumber(txtHNumber.Text.Trim())) |
| | | //{ |
| | | // MessageBox.Show("代码中不能出现连续‘.’并且首位末位不能为‘.’!", "提示"); |
| | | // return false; |
| | | //} |
| | | |
| | | //是否重复代码 |
| | | if (oDept.HavSameNumber(HItemID, txtHNumber.Text.Trim())) |
| | | { |
| | | MessageBox.Show("代码重复!", "提示"); |
| | | return false; |
| | | } |
| | | ////是否重复代码 |
| | | //if (oDept.HavSameNumber(HItemID, txtHNumber.Text.Trim())) |
| | | //{ |
| | | // MessageBox.Show("代码重复!", "提示"); |
| | | // return false; |
| | | //} |
| | | return true; |
| | | } |
| | | |
| | | //读取类 到 控件 |
| | | private void ShowData(long sItemID) |
| | | { |
| | | //DAL.ClsK3_Employee_View oEmp = new DAL.ClsK3_Employee_View(); |
| | | //if (oDeptHlp.GetInfoByID(sItemID)) |
| | | //{ |
| | | // txtHNumber.Text = oDeptHlp.omodel.HNumber.ToString(); |
| | | // txtHHelpCode.Text = oDeptHlp.omodel.HHelpCode.ToString(); |
| | | // txtHName.Text = oDeptHlp.omodel.HName.ToString(); |
| | | // txtHEmpID.Tag = Convert.ToInt64(oDeptHlp.omodel.HEmpID.ToString()); |
| | | // if (oEmp.GetInfoByID(oDeptHlp.omodel.HEmpID)) |
| | | // { |
| | | // txtHEmpID.Text = oEmp.omodel.HName; |
| | | // txtHEmpID.Tag = oEmp.omodel.HItemID.ToString(); |
| | | // } |
| | | // else |
| | | // { |
| | | // txtHEmpID.Text = ""; |
| | | // } |
| | | // txtHNumber.Text = oDeptHlp.omodel.HNumber.ToString(); |
| | | // txtHRemark.Text = oDeptHlp.omodel.HRemark; |
| | | // txtHBarCode.Text = oDeptHlp.omodel.HBarCode; |
| | | // if (oDeptHlp.omodel.HStopflag) |
| | | // chkHStopflag.Checked = true; |
| | | // else |
| | | // chkHStopflag.Checked = false; |
| | | // HItemID = oDeptHlp.omodel.HItemID; |
| | | //} |
| | | { |
| | | if (oDeptHlp.GetInfoByID(sItemID)) |
| | | { |
| | | txtHNumber.Text = oDeptHlp.omodel.HNumber.ToString(); |
| | | txtHName.Text = oDeptHlp.omodel.HName.ToString(); |
| | | txtHNumber.Text = oDeptHlp.omodel.HNumber.ToString(); |
| | | txtHRemark.Text = oDeptHlp.omodel.HRemark; |
| | | if (oDeptHlp.omodel.HStopflag) |
| | | chkHStopflag.Checked = true; |
| | | else |
| | | chkHStopflag.Checked = false; |
| | | HItemID = oDeptHlp.omodel.HItemID; |
| | | } |
| | | } |
| | | //写入类 从控件 |
| | | private bool WriteClass() |
| | |
| | | return false; |
| | | } |
| | | //检查父级是否存在 |
| | | string sParent; |
| | | sParent = DBUtility.ClsPub.GetParentCode(txtHNumber.Text.Trim()); |
| | | if (sParent.Trim() == "") |
| | | { |
| | | oDept.oModel.HParentID = 0; |
| | | } |
| | | else |
| | | { |
| | | if (oDept.HavParentCode(sParent.Trim(), HItemID)) |
| | | { |
| | | oDept.oModel.HParentID = oDept.oModel.HItemID; |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show("上级代码不存在或被禁用!", "提示"); |
| | | return false; |
| | | } |
| | | } |
| | | //string sParent; |
| | | //sParent = DBUtility.ClsPub.GetParentCode(txtHNumber.Text.Trim()); |
| | | //if (sParent.Trim() == "") |
| | | //{ |
| | | // oDept.oModel.HParentID = 0; |
| | | //} |
| | | //else |
| | | //{ |
| | | // if (oDept.HavParentCode(sParent.Trim(), HItemID)) |
| | | // { |
| | | // oDept.oModel.HParentID = oDept.oModel.HItemID; |
| | | // } |
| | | // else |
| | | // { |
| | | // MessageBox.Show("上级代码不存在或被禁用!", "提示"); |
| | | // return false; |
| | | // } |
| | | //} |
| | | //得到短代码 |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(txtHNumber.Text.Trim()); |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | return false; |
| | | } |
| | | //保存原代码 |
| | | if (oDeptHlp.GetInfoByID(HItemID)) |
| | | { |
| | | oDept.HOldNumber = oDeptHlp.omodel.HNumber; |
| | | //是否新代码是自己子项目的 子项目 |
| | | if (sParent.Length >= oDept.HOldNumber.Length) |
| | | { |
| | | if (sParent.Substring(0, oDept.HOldNumber.ToString().Length) == oDept.HOldNumber.Trim()) |
| | | { |
| | | MessageBox.Show("新代码不能是自己的下级的子项目!", "提示"); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | oDept.HOldNumber = ""; |
| | | } |
| | | //string sShortNumber; |
| | | //sShortNumber = DBUtility.ClsPub.GetShortNumber(txtHNumber.Text.Trim()); |
| | | //if (sShortNumber.Trim() == "") |
| | | //{ |
| | | // return false; |
| | | //} |
| | | ////保存原代码 |
| | | //if (oDeptHlp.GetInfoByID(HItemID)) |
| | | //{ |
| | | // oDept.HOldNumber = oDeptHlp.omodel.HNumber; |
| | | // //是否新代码是自己子项目的 子项目 |
| | | // if (sParent.Length >= oDept.HOldNumber.Length) |
| | | // { |
| | | // if (sParent.Substring(0, oDept.HOldNumber.ToString().Length) == oDept.HOldNumber.Trim()) |
| | | // { |
| | | // MessageBox.Show("新代码不能是自己的下级的子项目!", "提示"); |
| | | // return false; |
| | | // } |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // oDept.HOldNumber = ""; |
| | | //} |
| | | //写入信息 |
| | | oDept.oModel.HShortNumber = sShortNumber; |
| | | oDept.oModel.HEndFlag = true; |
| | | oDept.oModel.HLevel = DBUtility.ClsPub.GetLevel(txtHNumber.Text.Trim()); |
| | | oDept.oModel.HNumber = txtHNumber.Text.Trim(); |
| | | oDept.oModel.HName = txtHName.Text.Trim(); |
| | | oDept.oModel.HStopflag = chkHStopflag.Checked; |
| | | //oDept.oModel.HShortNumber = ""; |
| | | //oDept.oModel.HEndFlag = true; |
| | | ////oDept.oModel.HLevel = DBUtility.ClsPub.GetLevel(txtHNumber.Text.Trim()); |
| | | //oDept.oModel.HNumber = txtHNumber.Text.Trim(); |
| | | //oDept.oModel.HName = txtHName.Text.Trim(); |
| | | //oDept.oModel.HStopflag = chkHStopflag.Checked; |
| | | oDept.oModel.HRemark = txtHRemark.Text.Trim(); |
| | | return true; |
| | | } |
| | |
| | | BLL.ClsPub_BLL.Sub_ShowStopFlag(grdMain, Fun_GetCol("禁用标记")); |
| | | } |
| | | |
| | | |
| | | |
| | | private void button1_Click(object sender, EventArgs e) |
| | | { |
| | | oDept.oModel.HRemark = txtHRemark.Text.Trim(); |
| | | if (Save()) |
| | | { |
| | | MessageBox.Show("保存完毕!", "提示"); |
| | | } |
| | | else |
| | | { |
| | | MessageBox.Show("保存失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示"); |
| | | } |
| | | if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_Modify) |
| | | { |
| | | InputMode = DBUtility.ClsPub.Enum_InputMode.InputMode_View; |
| | | RefreshTool(); |
| | | } |
| | | } |
| | | } |
| | | } |