public void selectArea(int empid) { DataTable dt = AreaEmployeeMapping.Get_EmployeeArea_Mapping(empid).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { foreach (ListItem item in Chkarea.Items) { if (item.Value == dt.Rows[i]["AreaID"].ToString()) { item.Selected = true; } } } }
protected void btnSavE_Click(object sender, EventArgs e) { try { string Empcode = txtempCode.Text.Trim().Split(Constants.splitseperator)[0].ToString().Trim(); string DepartmentID = txtDepCode.Text.Trim().Split(Constants.splitseperator)[0].ToString().Trim(); Employee _objEmployee = new Employee(); string JoinDate = txtjoin.Text.Split('/')[1] + "/" + txtjoin.Text.Split('/')[0] + "/" + txtjoin.Text.Split('/')[2]; string ResignationDate = txtResign.Text.Split('/')[1] + "/" + txtResign.Text.Split('/')[0] + "/" + txtResign.Text.Split('/')[2]; _objEmployee.JoinDate = Convert.ToDateTime(JoinDate); _objEmployee.ResignationDate = Convert.ToDateTime(ResignationDate); _objEmployee.EmpID = Convert.ToInt32(LblEmpID.Text); _objEmployee.EmpCode = Empcode; _objEmployee.FirstName = txtFname.Text.Trim(); _objEmployee.MiddleName = txtMname.Text.Trim(); _objEmployee.LastName = txtLname.Text.Trim(); _objEmployee.Address = txtAdd.Text.Trim(); _objEmployee.State = DDLstate.SelectedValue; if (Convert.ToString(DDLcity.SelectedValue) == "0") //rajnish { _objEmployee.City = ""; //rajnish } else //rajnish { _objEmployee.City = Convert.ToString(DDLcity.SelectedItem); //rajnish } _objEmployee.Zip = txtzipCode.Text.Trim(); _objEmployee.Phone1 = txtphne1.Text.Trim(); _objEmployee.Phone2 = txtphne2.Text.Trim(); _objEmployee.Gender = Rdogender.Text; _objEmployee.DOB = txtDob.Text.Trim(); _objEmployee.Qualification = ddlqulification.SelectedItem.Value; _objEmployee.Designation = DDlDesignation.SelectedItem.Value; _objEmployee.EmailID = txtEmail.Text.Trim(); _objEmployee.DepartmentID = DepartmentID; _objEmployee.ZoneID = Convert.ToInt32(DDLzone.SelectedValue); _objEmployee.SuperZoneID = Convert.ToInt32(DDLsuperzone.SelectedValue); _objEmployee.AreaZoneID = Convert.ToInt32(DDLareazone.SelectedValue); _objEmployee.AreaID = Convert.ToInt32(0); _objEmployee.IsActive = Convert.ToBoolean(Chekacv.Checked); _objEmployee.IsDeleted = false; _objEmployee.SDZoneID = Convert.ToInt32(DDLSDZone.SelectedValue); if (lblImage.Text == "" || lblImage.Text.Split('.')[0].ToLower() != Empcode.ToLower()) { if (FileUpload1.HasFile) { _objEmployee.Photo = fileupload(Empcode); } } else { _objEmployee.Photo = lblImage.Text; } if (LblEmpID.Text == "0") { _objEmployee.Save(out EId); LblEmpID.Text = Convert.ToString(EId); Panel1.Visible = true; pnlEmployeeDetails.Visible = false; txtFname.Text = ""; txtMname.Text = ""; txtLname.Text = ""; txtAdd.Text = ""; txtzipCode.Text = ""; txtphne1.Text = ""; txtphne2.Text = ""; // txtjoin.Text = ""; // txtResign.Text = ""; txtDob.Text = ""; txtEmail.Text = ""; txtDepCode.Text = ""; txtempCode.Text = ""; // Chekacv.Checked = false; DDLstate.SelectedValue = null; DDLcity.SelectedValue = null; Rdogender.SelectedValue = null; DDlDesignation.SelectedValue = null; ddlqulification.SelectedValue = null; DDLsuperzone.SelectedValue = null; DDLzone.SelectedValue = null; DDLareazone.SelectedValue = null; DDLSDZone.SelectedValue = null; // DDLarea.SelectedValue = null; } else { _objEmployee.EmpID = Convert.ToInt32(LblEmpID.Text); _objEmployee.Update(); pnlEmployeeDetails.Visible = true; Panel1.Visible = false; btnSavE.Visible = false; filter.Visible = true; grdEmpDetails.DataSource = BindGvEmpDetail(); grdEmpDetails.DataBind(); } int i = 0; foreach (ListItem lst in Chkarea.Items) { if (lst.Selected == true) { if (lst.Value.ToString() == "0") { i = 1; } } if (i == 1) { if (lst.Value.ToString() != "0") { AreaEmployeeMapping _AEMapping = new AreaEmployeeMapping(); _AEMapping.EAmappingID = 0; _AEMapping.EmpID = Convert.ToInt32(LblEmpID.Text); _AEMapping.AreaID = Convert.ToInt32(lst.Value); _AEMapping.IsActive = true; _AEMapping.Save(); //Convert.ToInt32(LblEmpID.Text) //lst.Value } } else { if (lst.Selected == true) { AreaEmployeeMapping _AEMapping = new AreaEmployeeMapping(); _AEMapping.EAmappingID = 0; _AEMapping.EmpID = Convert.ToInt32(LblEmpID.Text); _AEMapping.AreaID = Convert.ToInt32(lst.Value); _AEMapping.IsActive = true; _AEMapping.Save(); //Convert.ToInt32(LblEmpID.Text) //lst.Value } } } LblEmpID.Text = ""; if (ChkLogin.Checked == true) { UserLoginDetails _objUsreLoginDetails = new UserLoginDetails(); _objUsreLoginDetails.EmpID = Convert.ToInt32(LblEmpID.Text); _objUsreLoginDetails.RoleID = Convert.ToInt32(DdlRole.SelectedValue); _objUsreLoginDetails.Password = TxtPassword.Text.Trim(); _objUsreLoginDetails.IsActive = true; _objUsreLoginDetails.Save(); } MessageBox("Record saved successfully"); LblEmpID.Text = "0"; } catch { } }