private void btnSave_Click(object sender, EventArgs e) { bool save = false; Cursor = Cursors.WaitCursor; try { if (validate()) { save = true; EmployeeBAL _objBAL = new EmployeeBAL(); EmployeeModel _objModel = new EmployeeModel(); _objModel._Address = richTextBox1.Text; _objModel._AL = Convert.ToInt32(tbxAL.Text); _objModel._CL = Convert.ToInt32(tbxCL.Text); _objModel._SL = Convert.ToInt32(tbxSL.Text); _objModel._CNIC = tbxCNIC.Text; _objModel._Code = GetMaxCode(); _objModel._DepartmentID = Convert.ToInt32(cmbDepartment.SelectedValue); _objModel._DesignationID = Convert.ToInt32(cmbDesignation.SelectedValue); _objModel._DOB = Convert.ToDateTime(dtpDOB.Text); _objModel._DOJ = Convert.ToDateTime(dtpDOJ.Text); _objModel._EmployeeID = selectedRecordId; _objModel._FatherName = tbxFatherName.Text; _objModel._FirstName = tbxFirstName.Text; _objModel._IsActive = cbxIsActive.Checked; _objModel._IsMarried = cbxMarried.Checked; _objModel._LastName = tbxLastName.Text; _objModel._MobileNo = tbxMobileNo.Text; _objModel._Descripition = ""; _objModel._Salary = Convert.ToDouble((tbxSalary.Text == "") ? "0" : tbxSalary.Text); _objModel._ShiftID = Convert.ToInt32(cmbShift.SelectedValue); string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\"; if (Directory.Exists(appPath) == false) { Directory.CreateDirectory(appPath); } pictureBox1.Image.Save(appPath + _objModel._EmployeeID + ".png", ImageFormat.Png); _objModel._ImageUrl = appPath + _objModel._EmployeeID + ".png"; _objModel._ModifiedDate = SmartManger.BAL.Common.DateNow(); if (selectedRecordId == 0) { _objBAL.SaveEmployee(_objModel); } else { _objBAL.UpdateEmployee(_objModel); } MakeEmpty(); MessageBox.Show("Record Saved Successfully!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Cursor = Cursors.Default; if (save) { this.Close(); } } }