Exemplo n.º 1
0
        public Boolean addStaff(int id, string firstName, string surname, string address1, string address2, string category, double baseLocLat, double baseLocLon)
        {
            Staff Staff = new Staff
            {
                id         = id,
                firstName  = firstName,
                surname    = surname,
                address1   = address1,
                address2   = address2,
                category   = category,
                baseLocLat = baseLocLat,
                baseLocLon = baseLocLon
            };

            return(Service.AddStaff(Staff));
        }
        public ResponseResult <Cookie> Reg([FromBody] Staff staff)
        {
            ResponseResult <Cookie> result = new ResponseResult <Cookie>();

            try
            {
                StaffService staffService = new StaffService();
                result.Result = staffService.AddStaff(staff);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = e.Message;
            }
            return(result);
        }
Exemplo n.º 3
0
        //保存员工资料
        private void btnSaveStaff_Click(object sender, EventArgs e)
        {
            #region  验证数据

            if (this.txtIDCard.Text.Trim().Length == 0)
            {
                MessageBox.Show("身份证号码不能为空!", "提示信息");
                this.txtIDCard.Focus();
                return;
            }
            if (this.txtName.Text.Trim().Length == 0)
            {
                MessageBox.Show("姓名不能为空!", "提示信息");
                this.txtName.Focus();
                return;
            }
            if (this.cboGender.Text.Trim().Length == 0)
            {
                MessageBox.Show("性别不能为空!", "提示信息");
                this.cboGender.Focus();
                return;
            }
            //验证婚姻
            if (this.cboMarriage.SelectedIndex == -1)
            {
                MessageBox.Show("请选择婚姻状态!", "提示信息");
                this.cboMarriage.Focus();
                return;
            }
            //验证部门
            if (this.cboDepartment.SelectedIndex == -1)
            {
                MessageBox.Show("请选择部门!", "提示信息");
                this.cboDepartment.Focus();
                return;
            }
            //验证组别
            if (this.cboGroup.SelectedIndex == -1)
            {
                MessageBox.Show("请选择组别!", "提示信息");
                this.cboGroup.Focus();
                return;
            }
            //验证职位
            if (this.cboJob.SelectedIndex == -1)
            {
                MessageBox.Show("请选择职位!", "提示信息");
                this.cboJob.Focus();
                return;
            }
            //验证卡号
            if (this.txtAttCardNo.Text.Trim().Length == 0)
            {
                MessageBox.Show("卡号不能为空!", "提示信息");
                this.txtAttCardNo.Focus();
                return;
            }
            //验证学历
            if (this.cboJob.SelectedIndex == -1)
            {
                MessageBox.Show("请选择学历!", "提示信息");
                this.cboJob.Focus();
                return;
            }
            //验证专业
            if (this.txtMajor.Text.Trim().Length == 0)
            {
                MessageBox.Show("专业不能为空!", "提示信息");
                this.txtMajor.Focus();
                return;
            }
            //验证籍贯
            if (this.txtNativePlace.Text.Trim().Length == 0)
            {
                MessageBox.Show("籍贯不能为空!", "提示信息");
                this.txtNativePlace.Focus();
                return;
            }
            //验证民族
            if (this.txtNation.Text.Trim().Length == 0)
            {
                MessageBox.Show("民族不能为空!", "提示信息");
                this.txtNation.Focus();
                return;
            }

            //验证手机号
            if (this.txtMobilePhone.Text.Trim().Length == 0)
            {
                MessageBox.Show("手机号不能为空!", "提示信息");
                this.txtMobilePhone.Focus();
                return;
            }
            //验证入职日期
            if (this.dtpEntryDate.Text.Trim().Length == 0)
            {
                MessageBox.Show("入职日期不能为空!", "提示信息");
                this.dtpEntryDate.Focus();
                return;
            }
            //验证出生日期
            if (this.dtpBirthDate.Text.Trim().Length == 0)
            {
                MessageBox.Show("出生日期不能为空!", "提示信息");
                this.dtpBirthDate.Focus();
                return;
            }
            //验证户籍地址
            if (this.txtDomicile.Text.Trim().Length == 0)
            {
                MessageBox.Show("户籍地址不能为空!", "提示信息");
                this.txtDomicile.Focus();
                return;
            }
            //验证现居地址
            if (this.txtResidence.Text.Trim().Length == 0)
            {
                MessageBox.Show("现居地址不能为空!", "提示信息");
                this.txtResidence.Focus();
                return;
            }
            //联络人
            if (this.txtFriend.Text.Trim().Length == 0)
            {
                MessageBox.Show("联络人不能为空!", "提示信息");
                this.txtFriend.Focus();
                return;
            }
            //关系
            if (this.txtFriend.Text.Trim().Length == 0)
            {
                MessageBox.Show("关系不能为空!", "提示信息");
                this.txtFriend.Focus();
                return;
            }
            //亲友电话
            if (this.txtFriendPhone.Text.Trim().Length == 0)
            {
                MessageBox.Show("亲友电话为空!", "提示信息");
                this.txtFriendPhone.Focus();
                return;
            }
            #endregion

            #region 封装员工对象

            //删除工号中的D
            //string strJobNo = txtJobNo.Text.Substring(1);//截取第1个字符起的字符,

            Staff objStaff = new Staff()
            {
                //JobNo = Convert.ToInt32(strJobNo),//工号和员工ID
                SfAttCardNo      = txtAttCardNo.Text.Trim(),
                SfDepartmentName = cboDepartment.Text.Trim(),
                SfGroupName      = cboGroup.Text.Trim(),
                SfJobName        = cboJob.Text.Trim(),
                SfName           = this.txtName.Text.Trim(),
                SfGender         = this.cboGender.Text.Trim(),
                SfAge            = Convert.ToInt32(this.txtAge.Text.Trim()),
                SfSeniority      = Convert.ToDouble(this.txtAge.Text.Trim()),
                SfMarriage       = this.cboMarriage.Text.Trim(),
                SfEducation      = this.cboEducation.Text.Trim(),
                SfMajor          = txtMajor.Text.Trim(),
                SfNativePlace    = txtNativePlace.Text.Trim(),
                SfEntryDate      = Convert.ToDateTime(dtpEntryDate.Text.Trim()),
                SfBirthDate      = Convert.ToDateTime(dtpBirthDate.Text.Trim()),
                SfDomicile       = txtDomicile.Text.Trim(),
                SfResidence      = txtRelation.Text.Trim(),
                SfIdCard         = txtIDCard.Text.Trim(),
                SfIntroducer     = txtIntroducer.Text.Trim(),
                SfFriend         = txtFriend.Text.Trim(),
                SfRelation       = txtRelation.Text.Trim(),
                SfFriendsPhone   = txtFriendPhone.Text.Trim(),
            };

            #endregion

            #region 调用后台数据访问方法添加对象

            try
            {
                if (objStaffService.AddStaff(objStaff) == 1)
                {
                    DialogResult result = MessageBox.Show("新员工添加成功!是否继续添加?", "提示信息", MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)//清空用户的输入
                    {
                        foreach (Control item in Controls)
                        {
                            if (item is ComboBox)
                            {
                                item.Text = "";
                            }
                        }
                        foreach (Control item in Controls)
                        {
                            if (item is DateTimePicker)
                            {
                                item.Text = "";
                            }
                        }

                        //清除文本框
                        foreach (Control item in this.Controls)
                        {
                            if (item is TextBox)
                            {
                                item.Text = "";
                            }
                        }
                        this.txtIDCard.Focus();
                    }
                }
                else
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            #endregion
        }