using LYFZ.BLL; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.OAShopManagement { public class frmAddRequestLeave : LYFZ.Software.UI.OAShopManagement.frmAddRequestLeave { public frmAddRequestLeave(){ LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.comboBoxTreeViewEx1); this.btnRelease.Click += btnRelease_Click; this.btnClose.Click += btnClose_Click; this.Load += frmReleaseTask_Load; this.comboBoxTreeViewEx1.IsNodeMouseClick = true; this.btnSet.Click += btnSet_Click; cmbCategory.TreeView.NodeMouseClick += TreeView_NodeMouseClick; } void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode trNode = e.Node; int iNodeIndex =0; while(iNodeIndex<10) { if (trNode.Parent==null) { if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper()) { SetFormDesignControl(false); } else if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper()) { SetFormDesignControl(true); } break; } else { trNode = trNode.Parent; } iNodeIndex++; } } bool CheckTypeByLeave() { TreeNode trNode = cmbCategory.TreeView.SelectedNode; int iNodeIndex = 0; while (iNodeIndex < 10) { if (trNode.Parent == null) { if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper()) { return false; } else if (trNode.Name == BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper()) { return true; } break; } else { trNode = trNode.Parent; } iNodeIndex++; } return false; } void btnSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet frm = new LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet(); frm.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper(); frm.Version = "Version"; if (frm.ShowDialog() == DialogResult.OK) { FinancialManagement.frmEditStatisticsProgram.LoadAllSystemCategory(); FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory( new string[]{ BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper(), BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper() } , this.cmbCategory.TreeView); } } BLL_ErpShopEvententry ctbll = new BLL_ErpShopEvententry(); string _id = ""; /// /// ID /// public string ID { get { return this._id; } set { this._id = value; } } Model.Model_ErpShopEvententry model = new Model.Model_ErpShopEvententry(); void frmReleaseTask_Load(object sender, EventArgs e) { FinancialManagement.frmEditStatisticsProgram.BindTreeView_SystemCategory(new string[]{ BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.事项类别).ToUpper(), BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.请假类别).ToUpper() } , this.cmbCategory.TreeView); if (!string.IsNullOrEmpty(this.ID)) { model = ctbll.GetModel(Convert.ToInt32(ID)); FinancialManagement.frmEditStatisticsProgram.SetSelectItme(this.cmbCategory, model.Matter_Category); this.comboBoxTreeViewEx1.Text = frmMattersApply.UserIDToName(model.Matter_UpdateName); this.comboBoxTreeViewEx1.Tag = model.Matter_UpdateName; this.txtTitle.Text = model.Matter_Title; this.txtInfo.Text = model.Matter_content; this.dateTimePickerStar.Value = model.Matter_StarLeaveTime; this.dateTimePickerEnd.Value = model.Matter_EndLeaveTime; } SetFormDesignControl(false); } void SetFormDesignControl(bool b) { labelEx3.Visible = b; dateTimePickerStar.Visible = b; dateTimePickerEnd.Visible = b; labelEx6.Visible = b; if(b) { labelEx4.Location = new System.Drawing.Point(labelEx4.Location.X, 137); txtInfo.Location = new System.Drawing.Point(txtInfo.Location.X, 132); txtInfo.Size = new System.Drawing.Size(txtInfo.Size.Width, 214); btnRelease.Location = new System.Drawing.Point(btnRelease.Location.X, 352); btnClose.Location = new System.Drawing.Point(btnClose.Location.X, 352); } else { labelEx4.Location = new System.Drawing.Point(labelEx4.Location.X, 101); txtInfo.Location = new System.Drawing.Point(txtInfo.Location.X, 98); txtInfo.Size = new System.Drawing.Size(txtInfo.Size.Width, 247); btnRelease.Location = new System.Drawing.Point(btnRelease.Location.X, 352); btnClose.Location = new System.Drawing.Point(btnClose.Location.X, 352); } } void btnClose_Click(object sender, EventArgs e) { this.Close(); } void btnRelease_Click(object sender, EventArgs e) { if (this.cmbCategory.TreeView.SelectedNode == null) { MessageBoxCustom.Show("请选申请请假类别"); return; } if (string.IsNullOrEmpty(this.txtTitle.Text.Trim())) { MessageBoxCustom.Show("请输入申请请假主题"); return; } if (this.comboBoxTreeViewEx1.Tag == null) { MessageBoxCustom.Show("请选申请请假审批人"); return; } if (string.IsNullOrEmpty(this.txtInfo.Text.Trim())) { MessageBoxCustom.Show("请输入申请请假事由"); return; } if (this.txtTitle.Text.Trim().Length > 100) { MessageBoxCustom.Show("申请请假主题不能超过100个字"); return; } if (this.txtInfo.Text.Trim().Length > 200) { MessageBoxCustom.Show("申请请假事由不能超过200个字"); return; } bool checkLeave = CheckTypeByLeave(); if (checkLeave) { if (this.dateTimePickerStar.Value < SDateTime.Now.AddMinutes(-30)) { MessageBoxCustom.Show("申请请假主开始时间不能为过去时间"); return; } if (this.dateTimePickerStar.Value >= this.dateTimePickerEnd.Value) { MessageBoxCustom.Show("申请请假主开始时间不能小于终止时间"); return; } } model.Matter_ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId(); model.Matter_UpdateName = comboBoxTreeViewEx1.Tag.ToString(); model.Matter_content = txtInfo.Text.Trim(); model.Matter_Title = this.txtTitle.Text.Trim(); model.Matter_CreateDatetime = SDateTime.Now; model.Matter_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; model.Matter_Category = this.cmbCategory.TreeView.SelectedNode.Name; model.Matter_state = state.申请中.ToString(); model.Matter_Type = 1; if (checkLeave) { model.Matter_StarLeaveTime = this.dateTimePickerStar.Value; model.Matter_EndLeaveTime = this.dateTimePickerEnd.Value; } //model.Matter_InstructedTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); //model.Matter_LeadershipInstruction = ""; model.Matter_opinion = ""; model.Matter_UpdateDatetime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime(); if (model.ID > 0) { if (ctbll.Update(model)) { System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ShopEvententryPushMessage), model); MessageBoxCustom.Show("重新申请发送成功"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxCustom.Show("重新申请发送失败"); return; } } else { if (ctbll.Add(model)) { System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ShopEvententryPushMessage), model); MessageBoxCustom.Show("申请发送成功"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxCustom.Show("申请发送成功"); return; } } } /// /// 发布时推送消息 /// void ShopEvententryPushMessage(object b) { try { if (b != null) { LYFZ.Model.Model_ErpShopEvententry eModel = (LYFZ.Model.Model_ErpShopEvententry)b; ctbll.ShopEvententryPushMessage(eModel); } } catch { } } } }