Exemple #1
0
        private void SaveData()
        {
            try
            {
                if (ValidateData())
                {
                    int flag = 0;
                    StaffDataManagement data = new StaffDataManagement();
                    data.Username      = txtUsername.Text.Trim();
                    data.EmpCode       = txtEmpCode.Text.Trim();
                    data.MarketingCode = txtMarketingCode.Text.Trim();
                    data.StaffNameTH   = txtStaffNameTH.Text.Trim();
                    data.TelNo         = txtTellNo.Text.Trim();
                    data.StaffEmail    = txtStaffEmail.Text.Trim();
                    data.PositionId    = cmbPosition.SelectedItem.Value;
                    data.StaffTypeId   = decimal.Parse(cmbStaffType.SelectedItem.Value);
                    data.Team          = txtTeam.Text.Trim();
                    data.BranchCode    = cmbBranchCode.SelectedItem.Value;
                    data.StaffId       = int.Parse(txtStaffId.Text.Trim());
                    if (rdNormal.Checked == true)
                    {
                        data.Is_Deleted = 0;
                    }
                    else if (rdRetire.Checked == true)
                    {
                        data.Is_Deleted = 1;
                    }

                    if (cmbHeadStaffId.Items.Count > 0 && cmbHeadStaffId.SelectedItem.Value != "")
                    {
                        data.HeadStaffId = int.Parse(cmbHeadStaffId.SelectedItem.Value);
                    }
                    else
                    {
                        data.HeadStaffId = null;
                    }

                    if (cmbDepartment.Items.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(cmbDepartment.SelectedItem.Value))
                        {
                            data.DepartmentId = int.Parse(cmbDepartment.SelectedItem.Value);
                        }
                    }
                    if (cmbCocTeam.Items.Count > 0)
                    {
                        data.CocTeam = cmbCocTeam.SelectedItem.Value;
                    }

                    if (txtOldIsDeleted.Text.Trim() != txtNewIsDeleted.Text.Trim())
                    {
                        flag = 1;
                    }

                    string staffId = StaffBiz.UpdateStaff(data, HttpContext.Current.User.Identity.Name, flag);

                    AppUtil.ClientAlert(Page, "บันทึกข้อมูลเจ้าหน้าที่สำเร็จ");
                    txtStaffId.Text = staffId;
                    InitialControl();
                    LoadStaffData();
                    CheckConditionOper();
                    SetDept();
                    upInfo.Update();
                }
                else
                {
                    AppUtil.ClientAlert(Page, "กรุณาระบุข้อมูลให้ครบถ้วน");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }