예제 #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);
            }
        }