protected void btnAddPhone_Click(object sender, EventArgs e) { string Active; if (chkPhone.Checked) { Active = "Y"; } else { Active = "N"; } List <ATTPhone> lstPhone = new List <ATTPhone>(); try { if (this.ddlPhoneType.SelectedIndex == 0) { this.lblStatusMessage.Text = "Please Select Phone Type"; this.programmaticModalPopup.Show(); return; } if (this.txtOrgPhone.Text == "") { this.lblStatusMessage.Text = "Please Enter Phone"; this.programmaticModalPopup.Show(); return; } lstPhone = (List <ATTPhone>)Session["LstPhone"]; int phoneSeq = 0; if (this.grdPhone.SelectedIndex > -1) { phoneSeq = lstPhone[this.grdPhone.SelectedIndex].PSno; } ATTPhone objPhone = new ATTPhone ( ddlPhoneType.SelectedItem.Text, ddlPhoneType.SelectedValue, phoneSeq, txtOrgPhone.Text, Active, ((ATTUserLogin)Session["Login_User_Detail"]).UserName, phoneSeq == 0?"A":"E" ); if (this.grdPhone.SelectedIndex == -1) { lstPhone.Add(objPhone); } else { lstPhone[this.grdPhone.SelectedIndex] = objPhone; } grdPhone.DataSource = lstPhone; grdPhone.DataBind(); this.grdPhone.SelectedIndex = -1; this.txtOrgPhone.Text = ""; this.ddlPhoneType.SelectedIndex = 0; this.chkPhone.Checked = false; Session["LstPhone"] = lstPhone; } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
protected void btnSave_Click(object sender, EventArgs e) { try { lblStatusMessage.Text = ""; List <ATTOrganization> lstOrg = (List <ATTOrganization>)Session["OrgList"]; int orgID = 0; if (this.lstOrgList.SelectedIndex > -1) { orgID = lstOrg[this.lstOrgList.SelectedIndex].OrgID; } ATTOrganization objOrg = new ATTOrganization( orgID, this.txtOrgName_Rqd.Text.Trim(), this.ddlOrgType_Rqd.SelectedValue, this.ddlOrgSubType_Rqd.SelectedValue, (ddlOrgParent.SelectedValue.ToString() == "") ? 0 : int.Parse(this.ddlOrgParent.SelectedValue.ToString()) ); foreach (ListItem lst in lstOrgList.Items) { if (lst.Text.ToLower() == txtOrgName_Rqd.Text.Trim().ToLower() && orgID == 0) { this.lblStatusMessage.Text = "Organization Name Already Exists"; this.programmaticModalPopup.Show(); return; } } objOrg.OrgAddress = txtAddress_Rqd.Text.Trim(); objOrg.OrgDistrict = (ddlOrgDistrict_Rqd.SelectedValue.ToString() == "") ? 0 : int.Parse(ddlOrgDistrict_Rqd.SelectedValue.ToString()); objOrg.OrgStreetName = txtStreet.Text.Trim(); objOrg.OrgVdcMuni = (ddlVdcMun_Rqd.SelectedValue.ToString() == "") ? 0 : int.Parse(ddlVdcMun_Rqd.SelectedValue.ToString()); objOrg.OrgWardNo = (ddlWard_Rqd.SelectedValue.ToString() == "") ? 0 : int.Parse(ddlWard_Rqd.SelectedValue.ToString()); objOrg.OrgUrl = txtUrl.Text.Trim(); foreach (ATTOrganization Att in lstOrg) { if (txtCourtCode_Rqd.Text.Trim().ToLower() == Att.OrgEquCode.ToString().ToLower() && orgID == 0) { this.lblStatusMessage.Text = "Organization Code Already Exists"; this.programmaticModalPopup.Show(); return; } } if (this.ddlOrgType_Rqd.SelectedValue == "CRT" && int.Parse(txtCourtCode_Rqd.Text.ToString()) == 0 && orgID > 0) { this.lblStatusMessage.Text = "Organization Code Should Not be Zero!!"; this.programmaticModalPopup.Show(); return; } if (this.ddlOrgType_Rqd.SelectedValue == "CRT") { objOrg.OrgEquCode = (txtCourtCode_Rqd.Text.ToString() == "") ? 0 : int.Parse(txtCourtCode_Rqd.Text.ToString()); } else { objOrg.OrgEquCode = 0; } objOrg.LstPhone = (List <ATTPhone>)Session["LstPhone"]; //objOrg.LstFax = (List<ATTFax>)Session["LstFax"]; objOrg.LstEmail = (List <ATTEmail>)Session["LstEmail"]; ObjectValidation OV = BLLOrganization.Validate(objOrg); if (OV.IsValid == false) { lblStatusMessage.Text = OV.ErrorMessage; this.programmaticModalPopup.Show(); return; } int newOrgID = 0; newOrgID = BLLOrganization.SaveOrganization(objOrg); if (newOrgID != 0) { this.lblStatusMessage.Text = "Organization Information Saved Successfully"; this.programmaticModalPopup.Show(); } if (this.lstOrgList.SelectedIndex > -1) { lstOrg[this.lstOrgList.SelectedIndex].OrgID = newOrgID; lstOrg[this.lstOrgList.SelectedIndex].OrgName = this.txtOrgName_Rqd.Text.Trim(); lstOrg[this.lstOrgList.SelectedIndex].OrgType = this.ddlOrgType_Rqd.SelectedValue; lstOrg[this.lstOrgList.SelectedIndex].OrgSubType = this.ddlOrgSubType_Rqd.SelectedValue; lstOrg[this.lstOrgList.SelectedIndex].ParentId = int.Parse(this.ddlOrgParent.SelectedValue.ToString()); lstOrg[this.lstOrgList.SelectedIndex].OrgAddress = txtAddress_Rqd.Text.Trim(); lstOrg[this.lstOrgList.SelectedIndex].OrgDistrict = int.Parse(ddlOrgDistrict_Rqd.SelectedValue.ToString()); lstOrg[this.lstOrgList.SelectedIndex].OrgStreetName = txtStreet.Text.Trim(); lstOrg[this.lstOrgList.SelectedIndex].OrgVdcMuni = int.Parse(ddlVdcMun_Rqd.SelectedValue.ToString()); lstOrg[this.lstOrgList.SelectedIndex].OrgWardNo = int.Parse(ddlWard_Rqd.SelectedValue.ToString()); lstOrg[this.lstOrgList.SelectedIndex].OrgUrl = txtUrl.Text.Trim(); lstOrg[this.lstOrgList.SelectedIndex].OrgEquCode = int.Parse(txtCourtCode_Rqd.Text.ToString()); lstOrg[this.lstOrgList.SelectedIndex].LstPhone.Clear(); lstOrg[this.lstOrgList.SelectedIndex].LstEmail.Clear(); foreach (GridViewRow row in this.grdEmail.Rows) { ATTEmail orgEMail = new ATTEmail(row.Cells[0].Text, row.Cells[1].Text, row.Cells[2].Text, row.Cells[3].Text); lstOrg[this.lstOrgList.SelectedIndex].LstEmail.Add(orgEMail); } foreach (GridViewRow row in this.grdPhone.Rows) { ATTPhone orgPhone = new ATTPhone(row.Cells[0].Text, row.Cells[1].Text, row.Cells[2].Text, row.Cells[3].Text); lstOrg[this.lstOrgList.SelectedIndex].LstPhone.Add(orgPhone); } } else { objOrg.OrgID = newOrgID; lstOrg.Add(objOrg); } Session["OrgList"] = lstOrg; this.lstOrgList.DataSource = lstOrg; this.lstOrgList.DataTextField = "OrgName"; this.lstOrgList.DataValueField = "OrgId"; this.lstOrgList.DataBind(); ClearControls(); } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }