Ejemplo n.º 1
0
        protected void ButtonCondResultSentModal_Click(object sender, EventArgs e)
        {
            int buyerAppIdi = 0;
            //throw new ApplicationException("Test.");
            // check if the status is autaccepted
            // extract the record from DB
            string buyerAppIds = Request.Params["Id"] as string;

            if (String.IsNullOrEmpty(buyerAppIds))
            {
                return;
            }
            else if (!Int32.TryParse(buyerAppIds, out buyerAppIdi))
            {
                return;
            }

            DataUtils.BuyerDSTableAdapters.BuyerApplicationsTableAdapter bata = new DataUtils.BuyerDSTableAdapters.BuyerApplicationsTableAdapter();
            DataUtils.DataUtil.SetConnectionStrFromConfig(bata, null);
            DataUtils.BuyerDS.BuyerApplicationsDataTable badt = null;

            try
            {
                badt = bata.GetDataBy(buyerAppIdi);
            }
            catch (Exception ex)
            {
                this.lblCondApproveError.Text    = "Error loading MAB application Id:" + buyerAppIds + ex.Message + ex.StackTrace;
                this.lblCondApproveError.Visible = true;
                return;
            }

            if (badt.Rows.Count != 1)
            {
                this.lblCondApproveError.Text    = "Unique buyer Application not found for Id:" + buyerAppIds;
                this.lblCondApproveError.Visible = true;
                return;
            }

            DataUtils.BuyerDS.BuyerApplicationsRow newBuyerApp = badt[0];
            newBuyerApp.CondCreditDecisionInformed   = DateTime.Now;
            newBuyerApp.CondCreditDecisionInformedBy = "dvorakpj";

            try
            {
                int updates = bata.Update(badt);
                if (updates != 1)
                {
                    throw new ApplicationException("Failed to record notification of Conditional Decision for MAB App Id:" + buyerAppIds);
                }
            } catch (Exception ex)
            {
                this.lblCondApproveError.Text   += "Error recording notification of Conditional Decision for MAB App Id:" + buyerAppIds + ex.Message + ex.StackTrace;
                this.lblCondApproveError.Visible = true;
                return;
            }

            Response.Redirect("~/BuyerApplicantsNewAll.aspx");
        }
Ejemplo n.º 2
0
        protected void ButtonCondApprovedModal_Click(object sender, EventArgs e)
        {
            //cleanup UI
            this.lblCondApproveError.Text    = String.Empty;
            this.lblCondApproveError.Visible = false;

            int buyerAppIdi = 0;
            //throw new ApplicationException("Test.");
            // check if the status is autaccepted
            // extract the record from DB
            string buyerAppIds = Request.Params["Id"] as string;

            if (String.IsNullOrEmpty(buyerAppIds))
            {
                return;
            }
            else if (!Int32.TryParse(buyerAppIds, out buyerAppIdi))
            {
                return;
            }
            //InvestorApplicationDS investor = new InvestorApplicationDS();

            DataUtils.BuyerDSTableAdapters.BuyerApplicationsTableAdapter bata = new DataUtils.BuyerDSTableAdapters.BuyerApplicationsTableAdapter();
            DataUtils.BuyerDS.BuyerDataTable bdt = new DataUtils.BuyerDS.BuyerDataTable();
            DataUtils.DataUtil.SetConnectionStrFromConfig(bata, null);


            DataUtils.BuyerDSTableAdapters.BuyerTableAdapter bta = new DataUtils.BuyerDSTableAdapters.BuyerTableAdapter();
            DataUtils.DataUtil.SetConnectionStrFromConfig(bta, null);

            DataUtils.BuyerDS.BuyerApplicationsDataTable badt = null;

            try
            {
                badt = bata.GetDataBy(buyerAppIdi);
            } catch (Exception ex)
            {
                this.lblCondApproveError.Text    = "Error loading MAB application Id:" + buyerAppIds + ex.Message + ex.StackTrace;
                this.lblCondApproveError.Visible = true;
                return;
            }


            if (badt.Rows.Count != 1)
            {
                this.lblCondApproveError.Text    = "Unique buyer Application not found for Id:" + buyerAppIds;
                this.lblCondApproveError.Visible = true;
                return;
            }

            DataUtils.BuyerDS.BuyerApplicationsRow newBuyerApp = badt[0];

            if (null != newBuyerApp)
            {
                //test of current status
                if ((!newBuyerApp.IsCondCreditDecisionNull()) || (!(newBuyerApp.IsCondCreditDecisionDateNull())))
                {
                    this.lblCondApproveError.Text    = "This mAB Application has already been conditionally approved by:" + newBuyerApp.CondCreditDecisionBy + " on:" + newBuyerApp.CondCreditDecisionDate.ToString();
                    this.lblCondApproveError.Visible = true;
                    return;
                }

                DataUtils.BuyerDS.BuyerRow newBuyerOth  = null;
                DataUtils.BuyerDS.BuyerRow newBuyerPrim = bdt.NewBuyerRow();

                newBuyerPrim.LastName     = newBuyerApp.Primary_LastName;
                newBuyerPrim.FirstName    = newBuyerApp.Primary_FirstName;
                newBuyerPrim.DOB          = newBuyerApp.Primary_DOB;
                newBuyerPrim.Res_Street1  = newBuyerApp.Primary_Res_Street1;
                newBuyerPrim.Res_Suburb   = newBuyerApp.Primary_Res_Suburb;
                newBuyerPrim.Res_Postcode = newBuyerApp.Primary_Res_PostCode;
                newBuyerPrim.Res_State    = newBuyerApp.Primary_Res_State;
                newBuyerPrim.Res_Country  = newBuyerApp.Primary_Res_Country;
                newBuyerPrim.Gender       = "M";

                newBuyerPrim.MAStatus           = "C";
                newBuyerPrim.AppliedDate        = newBuyerApp.EntryDate;
                newBuyerPrim.BuyerApplicationId = newBuyerApp.Id;
                newBuyerPrim.Created            = DateTime.Now;
                newBuyerPrim.CreatedBy          = "dvorakpj";

                bdt.AddBuyerRow(newBuyerPrim);

                try
                {
                    int updates = bta.Update(bdt);
                    if (updates != 1)
                    {
                        throw new ApplicationException("Failed to insert Permanent Primary MAB record for MAB App Id:" + buyerAppIds + ";" + "expected 1 row insterted actually:" + updates);
                    }
                    newBuyerPrim.AcceptChanges();
                }
                catch (Exception ex)
                {
                    this.lblCondApproveError.Text   += "Error creating a permanent Primary Buyer record for Application:" + buyerAppIds + ex.Message + ex.StackTrace;
                    this.lblCondApproveError.Visible = true;
                    return;
                }

                // process Other applicant as well
                if ((newBuyerApp.ApplicantType != "Single") && (!newBuyerApp.IsOther_LastNameNull()))
                {
                    newBuyerOth = bdt.NewBuyerRow();

                    newBuyerOth.PrimaryBuyerId = newBuyerPrim.Id;

                    newBuyerOth.LastName     = newBuyerApp.Other_LastName;
                    newBuyerOth.FirstName    = newBuyerApp.Other_FirstName;
                    newBuyerOth.DOB          = newBuyerApp.Other_DOB;
                    newBuyerOth.Gender       = "M";
                    newBuyerOth.Res_Street1  = newBuyerApp.Other_Res_Street1;
                    newBuyerOth.Res_Suburb   = newBuyerApp.Other_Res_Suburb;
                    newBuyerOth.Res_Postcode = newBuyerApp.Other_Res_PostCode;
                    newBuyerOth.Res_State    = newBuyerApp.Other_Res_State;
                    newBuyerOth.Res_Country  = newBuyerApp.Other_Res_Country;

                    newBuyerOth.MAStatus           = "C";
                    newBuyerOth.AppliedDate        = newBuyerApp.EntryDate;
                    newBuyerOth.BuyerApplicationId = newBuyerPrim.BuyerApplicationId;
                    newBuyerOth.CreatedBy          = newBuyerPrim.CreatedBy;
                    newBuyerOth.Created            = DateTime.Now;

                    bdt.AddBuyerRow(newBuyerOth);

                    try
                    {
                        int updates2 = bta.Update(bdt);
                        if (updates2 != 1)
                        {
                            throw new ApplicationException("Failed to insert Permanent Other MAB record for MAB App Id:" + buyerAppIds + ";" + "expected 1 row insterted actually:" + updates2);
                        }
                        newBuyerOth.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        this.lblCondApproveError.Text   += "Error creating a permanent Other Buyer record for Application:" + buyerAppIds + ex.Message + ex.StackTrace;
                        this.lblCondApproveError.Visible = true;
                        return;
                    }
                }

                newBuyerApp.CondCreditDecision     = "C";
                newBuyerApp.CondCreditDecisionBy   = "dvorakpj";
                newBuyerApp.CondCreditDecisionDate = DateTime.Now;
                newBuyerApp.Modified   = newBuyerApp.CondCreditDecisionDate;
                newBuyerApp.ModifiedBy = newBuyerApp.CondCreditDecisionBy;

                try
                {
                    int updates3 = bata.Update(badt);
                    if (updates3 != 1)
                    {
                        throw new ApplicationException("Failed to update MAB Application Id:" + buyerAppIds + ";" + "expected 1 row updated actually:" + updates3);
                    }
                    newBuyerApp.AcceptChanges();
                }
                catch (Exception ex)
                {
                    this.lblCondApproveError.Text   += "Error recording a conditional approval for MAB Application:" + buyerAppIds + "\n" + ex.Message + "\n" + ex.StackTrace;
                    this.lblCondApproveError.Visible = true;
                    return;
                }

                //Update internal IDs
                byte expUpdts = 0;
                IManagePermMABuyerID idMgr = new PermIDManager();
                // BuyerDS.BuyerDataTable dt = bta.GetDataBy(newBuyerPrim.Id);
                if ((null != newBuyerPrim) && (newBuyerPrim.Id > 0))
                {
                    //dt = bta.GetDataBy(newBuyerPrim.Id);

                    newBuyerPrim.MABuyerId = idMgr.AllocatePermMABID(newBuyerPrim.Id);
                    //newBuyerPrim.O
                    expUpdts++;
                }

                if ((null != newBuyerOth) && (newBuyerOth.Id > 0))
                {
                    newBuyerOth.MABuyerId = idMgr.AllocatePermMABID(newBuyerOth.Id);
                    expUpdts++;
                }
                if (expUpdts > 0)
                {
                    try

                    {
                        int updates4 = bta.Update(bdt);
                        if (updates4 != expUpdts)
                        {
                            throw new ApplicationException("Failed to allocate Permanent ID to new MAB records for MAB App Id:" + buyerAppIds + ";" + "expected 1 row insterted actually:" + updates4);
                        }
                        badt.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        this.lblCondApproveError.Text   += "Error allocating permanent IDs for new Buyer records for MAB Application:" + buyerAppIds + ex.Message + ex.StackTrace;
                        this.lblCondApproveError.Visible = true;
                        return;
                    }
                }


                Response.Redirect("~/BuyerApplicantsNewAll.aspx");
            }
        }