Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        /// <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);
            }
        }