protected void SaveButton_Click(object sender, EventArgs e)
    {
        bool isError = false;

        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            FarmService.ContactInfo contact = new Irmac.MailingCycle.BLLServiceLoader.Farm.ContactInfo();

            contact.ContactId = 0;

            if (!ScheduleNumberTextBox.Text.Trim().Equals(""))
            {
                contact.ScheduleNumber = int.Parse(ScheduleNumberTextBox.Text);
            }
            else
            {
                contact.ScheduleNumber = 0;
            }

            contact.OwnerFullName = OwnerFullNameTextBox.Text;

            if (!LotTextBox.Text.Trim().Equals(""))
            {
                contact.Lot = int.Parse(LotTextBox.Text);
            }
            else
            {
                contact.Lot = 0;
            }

            contact.Block       = BlockTextBox.Text;
            contact.Subdivision = SubDivisionTextBox.Text;
            contact.Filing      = FilingTextBox.Text;
            contact.SiteAddress = SiteAddressTextBox.Text;

            if (!BedroomsTextBox.Text.Trim().Equals(""))
            {
                contact.Bedrooms = int.Parse(BedroomsTextBox.Text);
            }
            else
            {
                contact.Bedrooms = 0;
            }

            if (!FullBathTextBox.Text.Trim().Equals(""))
            {
                contact.FullBath = int.Parse(FullBathTextBox.Text);
            }
            else
            {
                contact.FullBath = 0;
            }

            if (!ThreeQuarterBathTextBox.Text.Trim().Equals(""))
            {
                contact.ThreeQuarterBath = int.Parse(ThreeQuarterBathTextBox.Text);
            }
            else
            {
                contact.ThreeQuarterBath = 0;
            }

            if (!HalfBathTextBox.Text.Trim().Equals(""))
            {
                contact.HalfBath = int.Parse(HalfBathTextBox.Text);
            }
            else
            {
                contact.HalfBath = 0;
            }

            if (!AcresTextBox.Text.Trim().Equals(""))
            {
                contact.Acres = float.Parse(AcresTextBox.Text);
            }
            else
            {
                contact.Acres = 0;
            }

            contact.ActMktComb     = ActMktCombTextBox.Text;
            contact.OwnerFirstName = OwnerFirstNameTextBox.Text;
            contact.OwnerLastName  = OwnerLastNameTextBox.Text;
            contact.OwnerAddress1  = OwnerAddress1TextBox.Text;
            contact.OwnerAddress2  = OwnerAddress2TextBox.Text;
            contact.OwnerCity      = OwnerCityTextBox.Text;
            contact.OwnerState     = OwnerStateTextBox.Text;
            contact.OwnerZip       = OwnerZipTextBox.Text;
            contact.OwnerCountry   = OwnerCountryTextBox.Text;
            contact.SaleDate       = DateTime.Parse(SaleDateTextBox.Text);

            if (!TransAmountTextBox.Text.Trim().Equals(""))
            {
                contact.TransAmount = decimal.Parse(TransAmountTextBox.Text);
            }
            else
            {
                contact.TransAmount = 0;
            }

            contact.LastModifyBy = LoginUserId;
            contact.PlotId       = int.Parse(PlotIdHiddenField.Value.ToString());

            farmService.AddContact(contact);
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE CREATE CONTACT:", exception);
            isError = true;
        }
        if (!isError)
        {
            Response.Redirect("~/Members/ViewPlot.aspx?plotId=" + PlotIdHiddenField.Value.ToString());
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (IsPrinterRole)
            {
                DeleteContactButton.Enabled = false;
                EditContactButton.Enabled   = false;
            }

            Int64 contactId = 0;
            if ((Request.QueryString["contactId"] != "") && (Request.QueryString["contactId"] != null))
            {
                Int64.TryParse(Request.QueryString["contactId"], out contactId);
            }

            if (contactId == 0)
            {
                Response.Redirect("~/Members/FarmManagement.aspx");
            }

            if ((Request.QueryString["parentPage"] != "") && (Request.QueryString["parentPage"] != null))
            {
                ParentPageHiddenField.Value = Request.QueryString["parentPage"];
            }
            else
            {
                ParentPageHiddenField.Value = "";
            }

            try
            {
                //Get the common web service instance.
                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                //Getting Required Data
                FarmService.ContactInfo contact = farmService.GetContactDetails(contactId);
                FarmService.PlotInfo    plot    = farmService.GetPlotDetail(contact.PlotId);
                FarmService.FarmInfo    farm    = farmService.GetFarmDetail(plot.FarmId);
                int contactCount = farmService.GetContactCountForPlot(contact.PlotId);

                int userId = farmService.GetUserIdForFarm(plot.FarmId);
                UserIdHiddenField.Value = userId.ToString();
                if (!IsAgentRole)
                {
                    ForAgentLiteral.Visible = true;
                    RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration();
                    RegistrationService.RegistrationInfo    regInfo    = regservice.GetDetails(userId);
                    ForAgentLiteral.Text            = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + " ";
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                }
                else
                {
                    ForAgentLiteral.Visible = false;
                }

                //Header Details
                FarmNameLabel.Text            = farm.FarmName;
                PlotNameLabel.Text            = plot.PlotName;
                ContactCountLabel.Text        = contactCount.ToString();
                ContactCountHiddenField.Value = contactCount.ToString();

                if (farmService.IsDefaultPlot(plot.PlotId))
                {
                    DefaultPlotFlagHiddenField.Value = "true";
                }
                else
                {
                    DefaultPlotFlagHiddenField.Value = "false";
                }

                CreatedOnLabel.Text  = contact.CreateDate.ToShortDateString();
                ModifiedOnLable.Text = contact.LastModifyDate.ToShortDateString();

                //Hidden Fields
                FarmIdHiddenField.Value    = farm.FarmId.ToString();
                PlotIdHiddenField.Value    = plot.PlotId.ToString();
                ContactIdHiddenField.Value = contact.ContactId.ToString();

                //Contact Details
                ContactIdLabel.Text        = contact.ContactId.ToString();
                ScheduleNumberLabel.Text   = contact.ScheduleNumber.ToString();
                OwnerFullNameLabel.Text    = contact.OwnerFullName;
                LotNumberLabel.Text        = contact.Lot.ToString();
                BlockLabel.Text            = contact.Block;
                SubdivisionLabel.Text      = contact.Subdivision;
                FilingLabel.Text           = contact.Filing;
                SiteAddressLabel.Text      = contact.SiteAddress;
                BedroomsLabel.Text         = contact.Bedrooms.ToString();
                FullBathLabel.Text         = contact.FullBath.ToString();
                ThreeQuarterBathLabel.Text = contact.ThreeQuarterBath.ToString();
                HalfBathLabel.Text         = contact.HalfBath.ToString();
                AcresLabel.Text            = contact.Acres.ToString();
                ActMktComboLabel.Text      = contact.ActMktComb;
                OwnerFirstNameLabel.Text   = contact.OwnerFirstName;
                OwnerLastNameLabel.Text    = contact.OwnerLastName;
                OwnerAddress1Label.Text    = contact.OwnerAddress1;
                OwnerArrdess2Label.Text    = contact.OwnerAddress2;
                OwnerCityLabel.Text        = contact.OwnerCity;
                OwnerStateLabel.Text       = contact.OwnerState;
                OwnerZipLabel.Text         = contact.OwnerZip;
                OwnerCountryLabel.Text     = contact.OwnerCountry;
                SaleDateLabel.Text         = contact.SaleDate.ToShortDateString();
                TransAmountLabel.Text      = contact.TransAmount.ToString();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
                ErrorLiteral.Text = "UNKNOWN ERROR: Contact Administrator";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Int64 contactId = 0;
            if ((Request.QueryString["contactId"] != "") && (Request.QueryString["contactId"] != null))
            {
                Int64.TryParse(Request.QueryString["contactId"], out contactId);
            }

            if (contactId == 0)
            {
                Response.Redirect("~/Members/FarmManagement.aspx");
            }

            if ((Request.QueryString["parentPage"] != "") && (Request.QueryString["parentPage"] != null))
            {
                ParentPageHiddenField.Value = Request.QueryString["parentPage"];
            }
            else
            {
                ParentPageHiddenField.Value = "";
            }

            try
            {
                // Get the common web service instance.

                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                FarmService.ContactInfo contact = farmService.GetContactDetails(contactId);

                int userId = farmService.GetUserIdForPlot(contact.PlotId);
                UserIdHiddenField.Value = userId.ToString();
                if (!IsAgentRole)
                {
                    ForAgentLiteral.Visible = true;
                    RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration();
                    RegistrationService.RegistrationInfo    regInfo    = regservice.GetDetails(userId);
                    ForAgentLiteral.Text            = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + " ";
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                }
                else
                {
                    ForAgentLiteral.Visible = false;
                }
                ContactIdLabel.Text          = contact.ContactId.ToString();
                ScheduleNumberTextBox.Text   = contact.ScheduleNumber.ToString();
                OwnerFullNameTextBox.Text    = contact.OwnerFullName;
                LotTextBox.Text              = contact.Lot.ToString();
                BlockTextBox.Text            = contact.Block;
                SubDivisionTextBox.Text      = contact.Subdivision;
                FilingTextBox.Text           = contact.Filing;
                SiteAddressTextBox.Text      = contact.SiteAddress;
                BedroomsTextBox.Text         = contact.Bedrooms.ToString();
                FullBathTextBox.Text         = contact.FullBath.ToString();
                ThreeQuarterBathTextBox.Text = contact.ThreeQuarterBath.ToString();
                HalfBathTextBox.Text         = contact.HalfBath.ToString();
                AcresTextBox.Text            = contact.Acres.ToString();
                ActMktCombTextBox.Text       = contact.ActMktComb;
                OwnerFirstNameTextBox.Text   = contact.OwnerFirstName;
                OwnerLastNameTextBox.Text    = contact.OwnerLastName;
                OwnerAddress1TextBox.Text    = contact.OwnerAddress1;
                OwnerAddress2TextBox.Text    = contact.OwnerAddress2;
                OwnerCityTextBox.Text        = contact.OwnerCity;
                OwnerStateTextBox.Text       = contact.OwnerState;
                OwnerZipTextBox.Text         = contact.OwnerZip;
                OwnerCountryTextBox.Text     = contact.OwnerCountry;
                SaleDateTextBox.Text         = contact.SaleDate.ToShortDateString();
                TransAmountTextBox.Text      = contact.TransAmount.ToString();
                PlotIdHiddenField.Value      = contact.PlotId.ToString();

                FarmService.PlotInfo plot = farmService.GetPlotDetail(Convert.ToInt32(PlotIdHiddenField.Value));
                PlotNameLabel.Text     = plot.PlotName;
                ContactCountLabel.Text = plot.ContactCount.ToString();
                CreateDateLabel.Text   = plot.CreateDate.ToShortDateString();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }