protected void btnOK_Click(object sender, EventArgs e) { lblStatusMessage.Text = ""; List <ATTDocumentsType> lstDocumentsType = (List <ATTDocumentsType>)Session["DocumentsType"]; int docTypeID = 0; try { if (this.DocumentsTypeList.SelectedIndex > -1) { docTypeID = lstDocumentsType[this.DocumentsTypeList.SelectedIndex].DocTypeID; } ATTDocumentsType objDocType = new ATTDocumentsType(docTypeID, this.txtDocTypeName_rqd.Text.Trim()); ObjectValidation OV = BLLDocumentsType.Validate(objDocType); if (OV.IsValid == false) { lblStatusMessage.Text = OV.ErrorMessage; this.programmaticModalPopup.Show(); return; } BLLDocumentsType.SaveDocumentsType(objDocType); if (this.DocumentsTypeList.SelectedIndex > -1) { lstDocumentsType[this.DocumentsTypeList.SelectedIndex].DocTypeName = this.txtDocTypeName_rqd.Text.Trim(); } else { objDocType = new ATTDocumentsType(objDocType.DocTypeID, this.txtDocTypeName_rqd.Text.Trim()); lstDocumentsType.Add(objDocType); } this.DocumentsTypeList.DataSource = lstDocumentsType; this.lblStatusMessage.Text = "Successfully Saved"; this.programmaticModalPopup.Show(); this.DocumentsTypeList.DataBind(); this.txtDocTypeName_rqd.Text = ""; this.DocumentsTypeList.SelectedIndex = -1; } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
void LoadDocumentsType() { try { List <ATTDocumentsType> lstDocumentsType; lstDocumentsType = BLLDocumentsType.GetDocumentsType(null); Session["DocumentsType"] = lstDocumentsType; this.DocumentsTypeList.DataSource = lstDocumentsType; this.DocumentsTypeList.DataTextField = "DocTypeName"; this.DocumentsTypeList.DataValueField = "DocTypeID"; this.DocumentsTypeList.DataBind(); } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }
protected void btnOK_Click(object sender, EventArgs e) { lblStatusMessage.Text = ""; List <ATTDocumentsType> lstDocumentsType = (List <ATTDocumentsType>)Session["DocumentsType"]; int docTypeID = 0; try { if (this.DocumentsTypeList.SelectedIndex > -1) { docTypeID = lstDocumentsType[this.DocumentsTypeList.SelectedIndex].DocTypeID; } ATTDocumentsType objDocType = new ATTDocumentsType(docTypeID, this.txtDocTypeName_rqd.Text.Trim()); ObjectValidation OV = BLLDocumentsType.Validate(objDocType); if (OV.IsValid == false) { lblStatusMessage.Text = OV.ErrorMessage; this.programmaticModalPopup.Show(); return; } bool exists = lstDocumentsType.Exists(delegate(ATTDocumentsType obj) { return(obj.DocTypeName == objDocType.DocTypeName); } ); if (exists) { this.lblStatusMessage.Text = "**सोहि नामको कागजपत्रको विवरण पहिले नै उपलब्द छ"; this.programmaticModalPopup.Show(); this.txtDocTypeName_rqd.Text = ""; this.txtDocTypeName_rqd.Focus(); this.DocumentsTypeList.SelectedIndex = -1; return; } BLLDocumentsType.SaveDocumentsType(objDocType); if (this.DocumentsTypeList.SelectedIndex > -1) { lstDocumentsType[this.DocumentsTypeList.SelectedIndex].DocTypeName = this.txtDocTypeName_rqd.Text.Trim(); } else { objDocType = new ATTDocumentsType(objDocType.DocTypeID, this.txtDocTypeName_rqd.Text.Trim()); lstDocumentsType.Add(objDocType); } this.DocumentsTypeList.DataSource = lstDocumentsType; if (this.DocumentsTypeList.SelectedIndex == -1) { this.lblStatusMessage.Text = "Documents Type Saved Successfully. "; this.programmaticModalPopup.Show(); } else { this.lblStatusMessage.Text = "Documents Type Updated Successfully. "; this.programmaticModalPopup.Show(); } this.DocumentsTypeList.DataBind(); this.txtDocTypeName_rqd.Text = ""; this.txtDocTypeName_rqd.Focus(); this.DocumentsTypeList.SelectedIndex = -1; } catch (Exception ex) { this.lblStatusMessage.Text = ex.Message; this.programmaticModalPopup.Show(); } }