/// <summary> /// Load the grid. /// </summary> protected void LoadGrid() { DataSet dsMyDataSet = null; MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); DataTable dt = new DataTable(); try { dsMyDataSet = milePostBuzObj.GetAllApprovalDetails(); if (dsMyDataSet.Tables[0].Rows.Count > CommonConstants.StatusZero) { GridView1.DataSource = dsMyDataSet; GridView1.Visible = CommonConstants.True; GridView1.DataBind(); } else { GridView1.Visible = CommonConstants.False; lblNoRecords.Visible = CommonConstants.True; lblBusinessReason.Visible = CommonConstants.False; txtReasonReject.Visible = CommonConstants.False; btnSubmit.Visible = CommonConstants.False; btnReset.Visible = CommonConstants.False; } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.AccountApproval); Response.Redirect(CommonConstants.Error); } finally { //dsMyDataSet.Dispose(); } }
/// <summary> /// Fatching row details into Textboxes on Edit button click. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals(CommonConstants.EditRow)) { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = grdView1.Rows[index]; Session[CommonConstants.SelectedRowIndex] = row.RowIndex; txtPolicyNo.Text = row.Cells[0].Text; txtPolicyNo.Enabled = CommonConstants.False; txtUserName.Text = row.Cells[2].Text; txtRequestDate.Text = row.Cells[3].Text; txtMailId.Text = row.Cells[4].Text; TextBox tbox = (TextBox)row.FindControl("GrdTxtBusinessReason"); txtBusinessReason.Text = tbox.Text.ToString(); txtRootSegCount.Text = row.Cells[6].Text; txtMachineSegCount.Text = row.Cells[7].Text; txtFaceSegCount.Text = row.Cells[8].Text; } if (e.CommandName.Equals(CommonConstants.DeleteRow)) { int status; int index = Convert.ToInt32(e.CommandArgument); PolicyDetailsBusinessEntity policyDetails = new PolicyDetailsBusinessEntity(); MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); UserInfoDetailsBusinessEntity userInfo = (UserInfoDetailsBusinessEntity)Session[CommonConstants.UserInfo]; try { GridViewRow row = grdView1.Rows[index]; policyDetails.PolicyNo = row.Cells[0].Text; policyDetails.UserId = userInfo.UserId; status = milePostBuzObj.DeletePolicyDetails(policyDetails); if (status == CommonConstants.StatusOne) { ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessDeleted, true); LoadGrid(); } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.Message, CommonConstants.PolicyEntry); Response.Redirect(CommonConstants.Error); } finally { if (!txtPolicyNo.Enabled) { txtPolicyNo.Enabled = CommonConstants.True; } txtPolicyNo.Text = string.Empty; txtRequestDate.Text = string.Empty; txtRootSegCount.Text = string.Empty; txtBusinessReason.Text = string.Empty; txtMachineSegCount.Text = string.Empty; txtFaceSegCount.Text = string.Empty; } } }
/// <summary> /// This method is used to populate the saved checkbox values /// </summary> private void PopulateCheckedValues() { ArrayList rowIndex = null; ArrayList rowIndexReject = null; try { if (Session[CommonConstants.CheckedItems] != null) { rowIndex = (ArrayList)Session[CommonConstants.CheckedItems]; } if (rowIndex != null && rowIndex.Count > CommonConstants.StatusZero) { foreach (GridViewRow gvrow in GridView1.Rows) { string policyNo = Convert.ToString(GridView1.DataKeys[gvrow.RowIndex].Value); if (rowIndex.Contains(policyNo)) { RadioButton rbApprove = (RadioButton)gvrow.FindControl(CommonConstants.RbApprove); rbApprove.Checked = CommonConstants.True; } } } if (Session[CommonConstants.CheckedRejected] != null) { if (Session[CommonConstants.CheckedRejected] != null) { rowIndexReject = (ArrayList)Session[CommonConstants.CheckedRejected]; } } if (rowIndexReject != null && rowIndexReject.Count > CommonConstants.StatusZero) { foreach (GridViewRow gvrow in GridView1.Rows) { string policyNo = Convert.ToString(GridView1.DataKeys[gvrow.RowIndex].Value); if (rowIndexReject.Contains(policyNo)) { RadioButton rbApprove = (RadioButton)gvrow.FindControl(CommonConstants.RbReject); rbApprove.Checked = CommonConstants.True; } } } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.AccountApproval); Response.Redirect(CommonConstants.Error); } }
/// <summary> /// Page indexing change. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { try { SaveCheckedValues(); GridView1.PageIndex = e.NewPageIndex; LoadGrid(); PopulateCheckedValues(); } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.AccountApproval); Response.Redirect(CommonConstants.Error); } }
/// <summary> /// This method is usefult to Load the grid. /// </summary> protected void LoadGrid() { DataSet ds = null; PolicyDetailsBusinessEntity policyDetails = new PolicyDetailsBusinessEntity(); UserInfoDetailsBusinessEntity userInfo = (UserInfoDetailsBusinessEntity)Session[CommonConstants.UserInfo]; MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); try { policyDetails.UserId = userInfo.UserId; policyDetails.PolicyNo = txtPolicyNo.Text.ToUpper(); policyDetails.StartDate = txtRequestDate.Text; policyDetails.EndDate = txtEndDate.Text; ds = milePostBuzObj.GetPolicyEnquiry(policyDetails); if (ds.Tables[0].Rows.Count > CommonConstants.StatusZero) { GrdView2.Visible = CommonConstants.True; GrdView2.DataSource = ds; GrdView2.DataBind(); } else { if (GrdView2.Visible) { GrdView2.Visible = CommonConstants.False; } lblNoRecords.Visible = CommonConstants.True; } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.PolicyEnquiry); Response.Redirect(CommonConstants.Error); } finally { ds.Dispose(); } }
/// <summary> /// This method is usefult to Load the grid. /// </summary> protected void LoadGrid() { DataSet ds = null; UserInfoDetailsBusinessEntity userInfo = (UserInfoDetailsBusinessEntity)Session["UserInfo"]; MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); try { ds = milePostBuzObj.GetPolicyDetails(userInfo); Cache[CommonConstants.PolicyUnapproved] = ds; if (ds.Tables[0].Rows.Count > CommonConstants.StatusZero) { grdView1.Visible = CommonConstants.True; grdView1.DataSource = ds; grdView1.DataBind(); txtUserName.Text = userInfo.UserName; txtMailId.Text = userInfo.EmailId; lblNoRecords.Visible = CommonConstants.False; } else { txtUserName.Text = userInfo.UserName; txtMailId.Text = userInfo.EmailId; grdView1.Visible = CommonConstants.False; lblNoRecords.Visible = CommonConstants.True; } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.PolicyEntry); Response.Redirect(CommonConstants.Error); } finally { //ds.Dispose(); } }
/// <summary> /// This method is used to save the checkedstate of values /// </summary> private void SaveCheckedValues() { ArrayList rowIndex = new ArrayList(); ArrayList rowIndexReject = new ArrayList(); Boolean hdnVal = CommonConstants.False; try { string policyNo = string.Empty; foreach (GridViewRow gvrow in GridView1.Rows) { policyNo = Convert.ToString(GridView1.DataKeys[gvrow.RowIndex].Value); bool resultApprove = ((RadioButton)gvrow.FindControl(CommonConstants.RbApprove)).Checked; bool resultReject = ((RadioButton)gvrow.FindControl(CommonConstants.RbReject)).Checked; // Check in the Session for Approve if (Session[CommonConstants.CheckedItems] != null) { rowIndex = (ArrayList)Session[CommonConstants.CheckedItems]; } if (resultApprove) { if (!rowIndex.Contains(policyNo)) { rowIndex.Add(policyNo); } } else { rowIndex.Remove(policyNo); } // Check in the Session for Reject if (Session[CommonConstants.CheckedRejected] != null) { rowIndexReject = (ArrayList)Session[CommonConstants.CheckedRejected]; } if (resultReject) { if (!rowIndexReject.Contains(policyNo)) { rowIndexReject.Add(policyNo); } hdnVal = CommonConstants.True; } else { rowIndexReject.Remove(policyNo); } } if (rowIndex != null && rowIndex.Count > CommonConstants.StatusZero) { Session[CommonConstants.CheckedItems] = rowIndex; } if (rowIndexReject != null && rowIndexReject.Count > CommonConstants.StatusZero) { Session[CommonConstants.CheckedRejected] = rowIndexReject; } if (hdnVal) { this.hdnReject.Value = CommonConstants.Reject; } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.AccountApproval); Response.Redirect(CommonConstants.Error); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ArrayList rowIndex = null; ArrayList rowIndexRejected = null; int status; //bool sendMailStatus = false; bool sendMailStatus = true; SaveCheckedValues(); UserInfoDetailsBusinessEntity userInfo = null; PolicyDetailsBusinessEntity policyDetails = null; MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); DataSet ds = milePostBuzObj.GetAllPolicyNumber(); try { if (Session[CommonConstants.CheckedItems] != null || Session[CommonConstants.CheckedRejected] != null) { rowIndex = (ArrayList)Session[CommonConstants.CheckedItems]; rowIndexRejected = (ArrayList)Session[CommonConstants.CheckedRejected]; if (Session[CommonConstants.UserInfo] != null) { userInfo = (UserInfoDetailsBusinessEntity)Session[CommonConstants.UserInfo]; } if (rowIndex != null) { if (rowIndex.Count > 1) { if (rowIndexRejected != null) { if (rowIndexRejected.Count > 1) { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgSelectAppRej; } } else { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgSelectApprove; } } else { if (rowIndexRejected != null) { if (rowIndexRejected.Count > 1 || rowIndexRejected.Count == 1) { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgSelectAppRej; } } else { policyDetails = new PolicyDetailsBusinessEntity(); policyDetails.UserId = userInfo.UserId; policyDetails.ApprovalId = userInfo.UserId; policyDetails.PolicyNo = rowIndex[0].ToString(); status = milePostBuzObj.UpdateApprovalDetails(policyDetails); if (status == CommonConstants.StatusOne) { LoadGrid(); ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessApprove, true); if (ds.Tables[0].Rows.Count > CommonConstants.StatusZero) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { policyDetails = new PolicyDetailsBusinessEntity(); if (rowIndex[0].ToString() == Convert.ToString(ds.Tables[0].Rows[i][0])) { policyDetails.PolicyNo = Convert.ToString(ds.Tables[0].Rows[i][0]); policyDetails.BusinessReason = Convert.ToString(ds.Tables[0].Rows[i][1]); policyDetails.MailId = Convert.ToString(ds.Tables[0].Rows[i][6]); break; } } } //sendMailStatus = milePostBuzObj.SendApproveRejectMail(policyDetails, userInfo, CommonConstants.ApproveInd); if (sendMailStatus) { LoadGrid(); if (lblNotSelected.Visible) { lblNotSelected.Visible = CommonConstants.False; } } } if (lblNotSelected.Visible) { lblNotSelected.Visible = CommonConstants.False; } } } } else { if (rowIndexRejected != null) { if (rowIndexRejected.Count > 1) { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgSelectReject; } else { if (txtReasonReject.Text == string.Empty) { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgProvideReason; } else { if (ds.Tables[0].Rows.Count > CommonConstants.StatusZero) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { policyDetails = new PolicyDetailsBusinessEntity(); if (rowIndexRejected[0].ToString() == Convert.ToString(ds.Tables[0].Rows[i][0])) { policyDetails.PolicyNo = rowIndexRejected[0].ToString(); policyDetails.BusinessReason = Convert.ToString(ds.Tables[0].Rows[i][1]); policyDetails.MailId = Convert.ToString(ds.Tables[0].Rows[i][6]); policyDetails.RejectedReason = txtReasonReject.Text; break; } } } //sendMailStatus = milePostBuzObj.SendApproveRejectMail(policyDetails, userInfo, CommonConstants.RejectInd); if (sendMailStatus) { LoadGrid(); ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SucccessReject, true); txtReasonReject.Text = string.Empty; if (lblNotSelected.Visible) { lblNotSelected.Visible = CommonConstants.False; } } } } } } } else { lblNotSelected.Visible = CommonConstants.True; lblNotSelected.Text = CommonConstants.MsgSelectAppRej; } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.AccountApproval); Response.Redirect(CommonConstants.Error); } finally { Session.Remove(CommonConstants.CheckedItems); Session.Remove(CommonConstants.CheckedRejected); } }
/// <summary> /// Adding new policy detials into database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { PolicyDetailsBusinessEntity policyDetails = new PolicyDetailsBusinessEntity(); MilePostBuzLogic milePostBuzObj = new MilePostBuzLogic(); UserInfoDetailsBusinessEntity userInfo = (UserInfoDetailsBusinessEntity)Session[CommonConstants.UserInfo]; int addStatus = CommonConstants.StatusZero; bool exist = false; int status = 0; bool sendMailStatus = false; DataSet dsPolicyUnapprove = (DataSet)Cache[CommonConstants.PolicyUnapproved]; DataSet dsAllPolicyNo = milePostBuzObj.GetAllPolicyNumber(); try { policyDetails.PolicyNo = txtPolicyNo.Text.Trim(); policyDetails.UserId = userInfo.UserId; policyDetails.UserName = userInfo.UserName; policyDetails.RequestDate = txtRequestDate.Text.Trim(); policyDetails.PhoneNumber = userInfo.PhoneNumber.Trim(); policyDetails.BusinessReason = txtBusinessReason.Text.Trim(); policyDetails.RootSegmentCount = Int16.Parse(txtRootSegCount.Text.Trim()); policyDetails.FaceSegmentCount = Int16.Parse(txtFaceSegCount.Text.Trim()); policyDetails.MachineSegmentCount = Int16.Parse(txtMachineSegCount.Text.Trim()); if (Session[CommonConstants.SelectedRowIndex] != null) { status = milePostBuzObj.UpdatePolicyDetails(policyDetails); if (status == CommonConstants.StatusOne) { Session.Remove(CommonConstants.SelectedRowIndex); exist = true; ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessUpdate, true); txtPolicyNo.Enabled = CommonConstants.True; txtPolicyNo.Text = string.Empty; txtRequestDate.Text = string.Empty; txtRootSegCount.Text = string.Empty; txtBusinessReason.Text = string.Empty; txtMachineSegCount.Text = string.Empty; txtFaceSegCount.Text = string.Empty; } LoadGrid(); } else { for (int i = 0; i < dsPolicyUnapprove.Tables[0].Rows.Count; i++) { if (txtPolicyNo.Text.ToUpper() == Convert.ToString(dsPolicyUnapprove.Tables[0].Rows[i][2])) { status = milePostBuzObj.UpdatePolicyDetails(policyDetails); if (status == CommonConstants.StatusOne) { LoadGrid(); exist = true; ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessUpdate, true); txtPolicyNo.Text = string.Empty; txtRequestDate.Text = string.Empty; txtRootSegCount.Text = string.Empty; txtBusinessReason.Text = string.Empty; txtMachineSegCount.Text = string.Empty; txtFaceSegCount.Text = string.Empty; } break; } } if (dsAllPolicyNo.Tables[0].Rows.Count > CommonConstants.StatusOne) { for (int i = 0; i < dsAllPolicyNo.Tables[0].Rows.Count; i++) { if (txtPolicyNo.Text.ToUpper() == Convert.ToString(dsAllPolicyNo.Tables[0].Rows[i][0])) { if (Convert.ToChar(dsAllPolicyNo.Tables[0].Rows[i][7]) == CommonConstants.ApproveIndN || Convert.ToChar(dsAllPolicyNo.Tables[0].Rows[i][7]) == CommonConstants.ApproveIndn) { ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.AddFailure, true); exist = true; break; } else { if (Convert.ToChar(dsAllPolicyNo.Tables[0].Rows[i][7]) == CommonConstants.ApproveIndY || Convert.ToChar(dsAllPolicyNo.Tables[0].Rows[i][7]) == CommonConstants.ApproveIndy) { ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.AlreadyApproved, true); if (lblNoRecords.Visible) { lblNoRecords.Visible = CommonConstants.False; } exist = true; break; } } } } } if (!exist) { addStatus = milePostBuzObj.AddPolicyDetails(policyDetails); if (addStatus == CommonConstants.StatusOne) { policyDetails.MailId = userInfo.EmailId; // sendMailStatus = milePostBuzObj.SendEmail(policyDetails); if (sendMailStatus) { LoadGrid(); //ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.MailSuccess, true); } ScriptManager.RegisterStartupScript(this, GetType(), CommonConstants.ShowAlert, CommonConstants.SuccessAdded, true); txtPolicyNo.Text = string.Empty; txtRequestDate.Text = string.Empty; txtRootSegCount.Text = string.Empty; txtBusinessReason.Text = string.Empty; txtMachineSegCount.Text = string.Empty; txtFaceSegCount.Text = string.Empty; } LoadGrid(); } } } catch (Exception ex) { HandleLogging.AddtoLogFile(ex.ToString(), CommonConstants.PolicyEntry); Response.Redirect(CommonConstants.Error); } finally { Session.Remove(CommonConstants.SelectedRowIndex); } }