Beispiel #1
0
        /// <summary>
        /// Save Out Employee.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(EmpIDTB.Text) ||
                    String.IsNullOrWhiteSpace(EmpNameTB.Text) ||
                    String.IsNullOrWhiteSpace(MobilePhoneTB.Text) ||
                    String.IsNullOrWhiteSpace(EmailTB.Text))
                {
                    if (String.IsNullOrWhiteSpace(EmailTB.Text))
                    {
                        EmailTB.BackColor = Color.MistyRose;
                        EmailTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text))
                    {
                        MobilePhoneTB.BackColor = Color.MistyRose;
                        MobilePhoneTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpNameTB.Text))
                    {
                        EmpNameTB.BackColor = Color.MistyRose;
                        EmpNameTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpIDTB.Text))
                    {
                        EmpIDTB.BackColor = Color.MistyRose;
                        EmpIDTB.Focus();
                    }

                    MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOutEmployee(EmpIDTB.Text.Trim()))
                {
                    EmpIDTB.BackColor = Color.MistyRose;
                    EmpIDTB.Focus();
                    MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CurEmployee.ParentEmpId))
                {
                    PEmpNameTB.Clear();
                    CurEmployee.DepId         = String.Empty;
                    CurEmployee.DepName       = String.Empty;
                    CurEmployee.ParentEmpId   = String.Empty;
                    CurEmployee.ParentEmpName = String.Empty;
                    MessageBox.Show("请选择外协人员的责任人", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CurEmployee.EmpId       = EmpIDTB.Text.Trim();
                CurEmployee.EmpName     = EmpNameTB.Text.Trim();
                CurEmployee.Sex         = SexMRB.Checked ? "M" : "F";
                CurEmployee.Hometown    = HometownTB.Text.Trim();
                CurEmployee.CardId      = CardIDTB.Text.Trim();
                CurEmployee.CardIssue   = CardIssueTB.Text.Trim();
                CurEmployee.CardAddress = CardAddressTB.Text.Trim();
                CurEmployee.CompanyName = CompanyNameTB.Text.Trim();
                CurEmployee.ProjectName = ProjectNameTB.Text.Trim();
                CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim();
                CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim();
                CurEmployee.Email       = EmailTB.Text.Trim();
                //CurEmployee.ParentEmpName = null;
                CurEmployee.Enabled = EmpStatusCB.Checked;
                CurEmployee.Comment = RemarkTB.Text.Trim();
                //CurEmployee.Photo = null;
                CurEmployee.PhotoLayout = (int)PhotoPanel.BackgroundImageLayout;

                var result = Common.ShowWait(() => {
                    EmpEntity.SaveOutEmployees(new List <OutEmployeeInfo> {
                        CurEmployee
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurEmployee, OriEmployee);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", String.Format("{0}外协人员:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveOutEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Save Employee.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(EmpIDTB.Text) ||
                    String.IsNullOrWhiteSpace(EmpNameTB.Text) ||
                    String.IsNullOrWhiteSpace(MobilePhoneTB.Text) ||
                    String.IsNullOrWhiteSpace(EmailTB.Text))
                {
                    if (String.IsNullOrWhiteSpace(EmailTB.Text))
                    {
                        EmailTB.BackColor = Color.MistyRose;
                        EmailTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(MobilePhoneTB.Text))
                    {
                        MobilePhoneTB.BackColor = Color.MistyRose;
                        MobilePhoneTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpNameTB.Text))
                    {
                        EmpNameTB.BackColor = Color.MistyRose;
                        EmpNameTB.Focus();
                    }
                    if (String.IsNullOrWhiteSpace(EmpIDTB.Text))
                    {
                        EmpIDTB.BackColor = Color.MistyRose;
                        EmpIDTB.Focus();
                    }

                    MessageBox.Show("请输入必填项(红色标示区域)", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && EmpEntity.ExistOrgEmployee(EmpIDTB.Text.Trim()))
                {
                    EmpIDTB.BackColor = Color.MistyRose;
                    EmpIDTB.Focus();
                    MessageBox.Show("工号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CurEmployee.DepId))
                {
                    DeptTB.Clear();
                    CurEmployee.DepId   = String.Empty;
                    CurEmployee.DepName = String.Empty;
                    MessageBox.Show("请选择所属部门", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                CurEmployee.EmpId       = EmpIDTB.Text.Trim();
                CurEmployee.EmpType     = ComUtility.DBNullWorkerTypeHandler(EmpTypeCB.SelectedValue);
                CurEmployee.EmpName     = EmpNameTB.Text.Trim();
                CurEmployee.EnglishName = EmpEnglishNameTB.Text.Trim();
                CurEmployee.Sex         = SexMRB.Checked ? "M" : "F";
                CurEmployee.CardId      = CardIDTB.Text.Trim();
                CurEmployee.Hometown    = HometownTB.Text.Trim();
                CurEmployee.BirthDay    = BirthDayDTP.Value;
                CurEmployee.Marriage    = ComUtility.DBNullMarriageTypeHandler(MarriageTypeCB.SelectedValue);
                CurEmployee.HomeAddress = HomeAddressTB.Text.Trim();
                CurEmployee.HomePhone   = HomePhoneTB.Text.Trim();
                CurEmployee.EntryDay    = EntryDayDTP.Value;
                CurEmployee.PositiveDay = PositiveDayDTP.Value;
                //CurEmployee.DepId = null;
                //CurEmployee.DepName = null;
                CurEmployee.DutyName    = DutyNameTB.Text.Trim();
                CurEmployee.OfficePhone = OfficePhoneTB.Text.Trim();
                CurEmployee.MobilePhone = MobilePhoneTB.Text.Trim();
                CurEmployee.Email       = EmailTB.Text.Trim();
                CurEmployee.Comment     = RemarkTB.Text.Trim();
                //CurEmployee.Photo = null;
                CurEmployee.PhotoLayout       = (int)PhotoPanel.BackgroundImageLayout;
                CurEmployee.Enabled           = !EmpStatusCB.Checked;
                CurEmployee.ResignationDate   = CurEmployee.Enabled ? ComUtility.DefaultDateTime : ResignationDateDTP.Value;
                CurEmployee.ResignationRemark = CurEmployee.Enabled ? ComUtility.DefaultString : ResignationRemarkTB.Text.Trim();

                var result = Common.ShowWait(() => {
                    EmpEntity.SaveOrgEmployees(new List <OrgEmployeeInfo> {
                        CurEmployee
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurEmployee, OriEmployee);
                    Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", String.Format("{0}员工:[{1},{2}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurEmployee.EmpId, CurEmployee.EmpName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveEmployeeForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Save Card.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(CurCard.WorkerId))
                {
                    EmpNameTB.Clear();
                    CurCard.DepId      = String.Empty;
                    CurCard.DepName    = String.Empty;
                    CurCard.WorkerId   = String.Empty;
                    CurCard.WorkerName = String.Empty;
                    MessageBox.Show("请选择持卡员工", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (String.IsNullOrWhiteSpace(CardSnTB.Text))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("请输入卡号", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add && CardEntity.ExistCard(CardSnTB.Text.Trim()))
                {
                    CardSnTB.Focus();
                    MessageBox.Show("卡号已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //CurCard.WorkerId = null;
                //CurCard.WorkerType = null;
                //CurCard.WorkerName = null;
                //CurCard.DepId = null;
                //CurCard.DepName = null;
                CurCard.CardSn      = CardSnTB.Text.Trim();
                CurCard.CardType    = ComUtility.DBNullCardTypeHandler(CardTypeCB.SelectedValue);
                CurCard.UID         = String.IsNullOrWhiteSpace(CardUIDTB.Text) ? "00000000" : CardUIDTB.Text.Trim().PadLeft(8, '0');
                CurCard.Pwd         = String.IsNullOrWhiteSpace(CardPwdTB.Text) ? "0000" : CardPwdTB.Text.Trim().PadLeft(4, '0');
                CurCard.BeginTime   = BeginTimeDTP.Value;
                CurCard.BeginReason = Convert.ToInt32(BeginReasonCB.SelectedValue) == 0 ? BeginReasonTB.Text.Trim() : BeginReasonCB.Text;
                CurCard.Comment     = CommentTB.Text.Trim();
                CurCard.Enabled     = EnabledCB.Checked;
                var result = Common.ShowWait(() => {
                    CardEntity.SaveCards(new List <CardInfo> {
                        CurCard
                    });
                }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                if (result == DialogResult.OK)
                {
                    Common.CopyObjectValues(CurCard, OriCard);
                    Common.WriteLog(DateTime.Now, CurBehavior == EnmSaveBehavior.Add ? EnmMsgType.Cardin : EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", String.Format("{0}卡片:[{1} - {2},{3}]", CurBehavior == EnmSaveBehavior.Add ? "新增" : "更新", CurCard.CardSn, CurCard.WorkerId, CurCard.WorkerName), null);
                    MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveCardForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }