private void BtnUpdate_Click(object sender, EventArgs e)
        {
            CityModel   city   = (CityModel)cmbCity.SelectedItem;
            CountyModel county = (CountyModel)cmbCounty.SelectedItem;


            int clientId = clientIdValue;

            //MessageBox.Show(cmbCity.SelectedIndex.ToString());
            int    clientAddressid = clientAddressIdValue;
            int    cityId          = (cmbCity.SelectedIndex == -1)? -1 :city.CityId;
            string cityName        = (cmbCity.SelectedIndex == -1) ? null : city.CityName;
            //MessageBox.Show(cityId.ToString());
            int          countyId   = (cmbCounty.SelectedIndex == -1) ? -1 : county.CountyId;
            string       countyName = (cmbCounty.SelectedIndex == -1) ? null : county.CountyName;
            string       streetName = txtStreetName.Text;
            string       streetNo   = txtStreetNo.Text;
            BLAddress    bl         = new BLAddress();
            AddressModel address    = bl.GetAddress(clientAddressid, cityName, countyName, streetName, streetNo);

            address.status = 2;
            parent.RefreshGridUpdate(address);
            //bl.UpdateAddress(clientId, clientAddressid, cityId, countyId, streetName, streetNo);
            //bl.AddAddress(clientId, cityId, countyId, streetName, streetNo);
            //MessageBox.Show("Adresa a fost modificata cu succes.");
        }
Пример #2
0
        internal BLAddress SetTaxSchedule(BLAddress _address, int _custKey)
        {
            address = _address;
            custKey = _custKey;

            if (address.IsGovernment)
            {
                GetGovernmentTaxSchedule();
                return(address);
            }

            switch (address.Data.State)
            {
            case "CA":
                GetCATaxSchedule();
                break;

            case "WA":
                GetWATaxSchedule();
                break;

            case "MO":
                GetMOTaxSchedule();
                break;

            default:
                GetTaxByCountry();
                break;
            }

            return(address);
        }
Пример #3
0
        // Handles update of the selected product
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                string billPostCode = (Session["User"] as BLUser).userAdmin ? "0" : tbxBillPostCode.Text;

                BLUser currentUser = new BLUser
                {
                    userID        = Convert.ToInt32(lblUserID.Text),
                    userFirstName = tbxFirstName.Text,
                    userLastName  = tbxLastName.Text,
                    userEmail     = tbxEmail.Text,
                    userPhone     = tbxPhone.Text,
                    billAddress   = BLAddress.fillAddress('B', tbxBillAddress.Text, tbxBillSuburb.Text, ddlBillState.SelectedValue, Convert.ToInt32(billPostCode)),
                    postAddress   = BLAddress.fillAddress('P', tbxPostAddress.Text, tbxPostSuburb.Text, ddlPostState.SelectedValue, Convert.ToInt32(tbxPostPostCode.Text)),
                    userAdmin     = (Session["User"] as BLUser).userAdmin,
                    userActive    = (Session["User"] as BLUser).userActive
                };

                Session["User"] = currentUser;

                BLUser.updateUser(currentUser);

                Session.Remove("User");

                Response.Redirect("~/UL/AdminManageUserAccounts");
            }
        }
        public ClientAddressForm(int _id)
        {
            id = _id;
            InitializeComponent();
            BLAddress bLAddress = new BLAddress();

            dataGridClientAddress.DataSource = bLAddress.Address(id);
            BLClient     bLClient = new BLClient();
            ClientModule client   = new ClientModule();

            client = bLClient.GetClientList(id, "", "", "", "", "")[0];

            txtClientName.Text    = client.ClientName;
            txtClientSurname.Text = client.ClientSurname;
            txtClientCode.Text    = client.ClientCode;
            txtEmail.Text         = client.Email;
            txtPhoneNo.Text       = client.PhoneNo;

            dataGridClientAddress.Columns["ClientId"].Visible        = false;
            dataGridClientAddress.Columns["ClientAddressId"].Visible = false;
            dataGridClientAddress.Columns["ClientName"].Visible      = false;
            dataGridClientAddress.Columns["ClientSurname"].Visible   = false;
            dataGridClientAddress.Columns["CityName"].HeaderText     = "Oras";
            dataGridClientAddress.Columns["CountyName"].HeaderText   = "Judet";
            dataGridClientAddress.Columns["StreetName"].HeaderText   = "Nume Strada";
            dataGridClientAddress.Columns["StreetNo"].HeaderText     = "Numar Strada";
            dataGridClientAddress.Columns["status"].Visible          = false;

            dataGridClientAddress.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
        private void AddressPage_Done(BLAddress address)
        {
            btnNext.Enabled = true;

            newCustomer.Id   = address.CustId;
            newCustomer.Name = address.Data.Name;
            newCustomer.PrimaryAddress.Name        = address.Data.Name;
            newCustomer.PrimaryAddress.Line1       = address.Data.Line1;
            newCustomer.PrimaryAddress.Line2       = address.Data.Line2;
            newCustomer.PrimaryAddress.City        = address.Data.City;
            newCustomer.PrimaryAddress.State       = address.Data.State;
            newCustomer.PrimaryAddress.Zip         = address.Data.Zip;
            newCustomer.PrimaryAddress.Country     = address.Data.Country;
            newCustomer.PrimaryAddress.Residential = address.Data.Residential;

            var primaryCustAddr = newCustomer.CustAddresses.FirstOrDefault(c => c.Type == CustAddrType.Primary);

            if (primaryCustAddr == null)
            {
                primaryCustAddr = new CustAddress {
                    Type = CustAddrType.Primary
                };
                newCustomer.CustAddresses.Add(primaryCustAddr);
            }

            primaryCustAddr.STaxSchdKey = address.SalesTaxKey;
            primaryIsGov = address.IsGovernment;
        }
Пример #6
0
        ///ADDRESS DATAGRIDVIEW CONTROL
        private void SetUpAddressDGVControl()
        {
            addressDataGridView = new AddressDataGridView()
            {
                Dock = DockStyle.Fill
            };
            addressDataGridView.ShowActiveColumn();
            addressDataGridView.Initialize(activeAddresses);
            addressDataGridView.SelectionChanged += (key) =>
            {
                bool proceed = NotifyIfAddressIsDirty();
                if (proceed)
                {
                    cachedAddrKeyForRowSelection = key;

                    currentAddress     = allAddresses.First(addr => addr.Data.Key == key);
                    currentCustAddress = customer.CustAddresses.First(c => c.Key == key);

                    SetFormToCurrentAddress();
                    CacheCurrentAddress();
                    CacheCustAddress();

                    btnSave.Enabled  = false;
                    statusLabel.Text = "";
                }
            };

            panelDGV.Controls.Add(addressDataGridView);
        }
        private void BtnGetAddress_Click(object sender, EventArgs e)
        {
            //ClientForm clientForm = new ClientForm();
            //int id = clientForm.id;
            //if (dataGridClientAddress.SelectedRows.Count == 0)
            //{
            //    MessageBox.Show("Trebuie sa selectati o adresa.");
            //    return;
            //}

            BLAddress bLAddress = new BLAddress();

            dataGridClientAddress.DataSource = bLAddress.Address(id);
            dataGridClientAddress.Columns["ClientId"].Visible        = false;
            dataGridClientAddress.Columns["ClientAddressId"].Visible = false;
            dataGridClientAddress.Columns["ClientName"].Visible      = false;
            dataGridClientAddress.Columns["status"].Visible          = false;
            dataGridClientAddress.Columns["ClientSurname"].Visible   = false;
            dataGridClientAddress.Columns["CityName"].HeaderText     = "Oras";
            dataGridClientAddress.Columns["CountyName"].HeaderText   = "Judet";
            dataGridClientAddress.Columns["StreetName"].HeaderText   = "Nume Strada";
            dataGridClientAddress.Columns["StreetNo"].HeaderText     = "Numar Strada";
            dataGridClientAddress.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            //txtClientFullName.Text = id.ToString();
        }
Пример #8
0
        internal BLAddress ValidateAndClassify(BLAddress address)
        {
            string addr1 = address.Data.Line1 ?? "";
            string addr2 = address.Data.Line2 ?? "";
            string city  = address.Data.City ?? "";
            string state = address.Data.State ?? "";
            string zip5  = address.Zip5 ?? "";
            string zip4  = address.Zip4 ?? "";

            int status;
            int classification;
            int count;

            int result = upsProxy.ValidateClassifyAddress(ref addr1, ref addr2, ref city, ref state, ref zip5, ref zip4, out status, out classification, out count);

            if (result != -1)
            {
                address.Data.Line1 = addr1;
                address.Data.Line2 = addr2;
                address.Data.City  = city;
                address.Data.State = state;
                address.Zip5       = zip5;
                address.Zip4       = zip4;

                address.Data.Residential = (short)classification == 2 ? (short)1 : (short)0;
                address.IsValidated      = true;
                return(address);
            }
            address.IsValidated = false;
            return(address);
        }
        private void MapAddressToBLAddress(Address sourceAddress, BLAddress destinationAddress, string sourceAddrType)
        {
            destinationAddress.Data.Name        = sourceAddress.Name ?? "";
            destinationAddress.Data.Line1       = sourceAddress.Line1 ?? "";
            destinationAddress.Data.Line2       = sourceAddress.Line2 ?? "";
            destinationAddress.Data.City        = sourceAddress.City ?? "";
            destinationAddress.Data.Zip         = sourceAddress.Zip;
            destinationAddress.Data.State       = sourceAddress.State ?? "";
            destinationAddress.Data.Country     = string.IsNullOrEmpty(sourceAddress.Country) ? "US" : sourceAddress.Country;
            destinationAddress.Data.Residential = sourceAddress.Residential;

            destinationAddress.SplitZipCode();

            switch (sourceAddrType)
            {
            case "Primary":
                destinationAddress.SalesTaxKey  = PrimTaxKey;
                destinationAddress.IsGovernment = PrimIsGovernment;
                break;

            case "Billing":
                destinationAddress.SalesTaxKey  = TaxKey;
                destinationAddress.IsGovernment = AddrIsGovernment;
                break;
            }
        }
Пример #10
0
        private void SetCurrentAddressFromSelectedRow()
        {
            var currentList = GetCurrentList();

            currentAddress = currentList.FirstOrDefault(c => c.Data.Key == cachedAddrKeyForRowSelection);

            if (currentAddress == null)
            {
                if (currentList.Count == 0)
                {
                    currentAddress      = new BLAddress();
                    currentAddress.Data = new Address();
                    currentCustAddress  = new CustAddress();
                }
                else
                {
                    currentAddress      = currentList[0];
                    currentAddress.Data = currentList[0].Data;
                    currentCustAddress  = customer.CustAddresses.First(c => c.Key == currentAddress.Data.Key);

                    CacheCurrentAddress();
                    CacheCustAddress();
                }
            }
            else
            {
                currentAddress.Data = currentList.First(c => c.Data.Key == cachedAddrKeyForRowSelection).Data;
                currentCustAddress  = customer.CustAddresses.First(c => c.Key == currentAddress.Data.Key);

                CacheCurrentAddress();
                CacheCustAddress();
            }
        }
        private void AddressControl_Done(BLAddress billingAddr)
        {
            address = billingAddr;
            Done(address);

            lblStatus.ForeColor = Color.Green;
            lblStatus.Text      = "Address have been validated.";
        }
        private void CmbClientFullName_SelectedIndexChanged(object sender, EventArgs e)
        {
            BLAddress           bLAddress      = new BLAddress();
            ClientFullNameModel clientFullName = (ClientFullNameModel)cmbClientFullName.SelectedItem;

            cmbAddress.DataSource    = bLAddress.GetFullAddress(clientFullName.ClientId);
            cmbAddress.DisplayMember = "FullAddress";
        }
        public void initAdrese(int id)
        {
            BLAddress blAdrese = new BLAddress();
            DataTable adrese   = blAdrese.GetClientAddresses(id);

            cbAdrese.DataSource    = adrese;
            cbAdrese.ValueMember   = "PartnerAddressId";
            cbAdrese.DisplayMember = "AdresaClient";
        }
Пример #14
0
        private void AddressControl_Done(BLAddress address)
        {
            if (address.IsDirty)
            {
                btnSave.Enabled = true;

                currentAddress.IsDirty     = address.IsDirty;
                currentAddress.IsValidated = address.IsValidated;

                currentAddress.Data.Name        = address.Data.Name;
                currentAddress.Data.Line1       = address.Data.Line1;
                currentAddress.Data.Line2       = address.Data.Line2;
                currentAddress.Data.City        = address.Data.City;
                currentAddress.Data.State       = address.Data.State;
                currentAddress.Data.Zip         = address.Data.Zip;
                currentAddress.Data.Country     = address.Data.Country;
                currentAddress.Data.Residential = address.Data.Residential;

                RemoveNullsOnEmptyAddressProperties();

                var custAddr        = customer.CustAddresses.FirstOrDefault(c => c.Key == currentAddress.Data.Key);
                var primaryCustAddr = customer.CustAddresses.FirstOrDefault(c => c.Key == customer.PrimaryAddrKey);
                var whseTerr        = GetWarehouseAndTerritory(currentAddress.Data.State);

                if (custAddr == null) //new entry
                {
                    custAddr = new CustAddress();
                    MapCustAddr(ref custAddr, primaryCustAddr);

                    custAddr.WhseKey           = whseTerr.Item1;
                    custAddr.SalesTerritoryKey = whseTerr.Item2;
                    custAddr.Key          = address.Data.Key;
                    custAddr.STaxSchdKey  = address.SalesTaxKey;
                    custAddr.CreateDate   = DateTime.Now;
                    custAddr.CreateUserID = userName;
                    custAddr.UpdateDate   = null;
                    custAddr.UpdateUserID = null;
                    custAddr.Type         = CustAddrType.CSA;

                    currentCustAddress = custAddr;
                }
                else //existing entry - doing update
                {
                    MapCustAddr(ref custAddr, primaryCustAddr);

                    custAddr.WhseKey           = whseTerr.Item1;
                    custAddr.SalesTerritoryKey = whseTerr.Item2;
                    custAddr.STaxSchdKey       = address.SalesTaxKey;
                    custAddr.UpdateDate        = DateTime.Now;
                    custAddr.UpdateUserID      = userName;
                    custAddr.Type = CustAddrType.CSA;
                }

                SetTaxRateTextBox();
            }
        }
Пример #15
0
        public void Initialize(int _custKey, CustomerService _service)
        {
            SetUserPermissions();

            currentAddress     = new BLAddress(new TaxService(), new ValidationService());
            currentCustAddress = new CustAddress();
            service            = _service;

            custKey = _custKey;
        }
        // Handles submission of admin registration form
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                string password = BLPassword.RandomString(10, true);
                string mailbody =
                    "<p>"
                    + "Hi,"
                    + "</p>"
                    + "<p>"
                    + "Below is the verification link needed to update your password (click to update):"
                    + "</p>"
                    + "<p>"
                    + "https://localhost:44326/UL/ChangePassword/" + tbxUsername.Text + "/" + password
                    + "</p>"
                    + "<br/>"
                    + "<p>"
                    + "Kind Regards,"
                    + "</p>"
                    + "<p>"
                    + "The JerseySure Team"
                    + "</p>";

                try
                {
                    BLEmail.SendEmail(tbxUsername.Text, "Admin Verification Link - JerseySure", mailbody);
                }
                catch (Exception ex)
                {
                    Response.Redirect("~/UL/ErrorPage/1");
                }


                BLUser newUser = new BLUser
                {
                    userFirstName = tbxFirstName.Text,
                    userLastName  = tbxLastName.Text,
                    userEmail     = tbxUsername.Text,
                    userPhone     = tbxPhone.Text,
                    billAddress   = null,
                    postAddress   = BLAddress.fillAddress('P', tbxAddress.Text, tbxSuburb.Text, ddlState.SelectedValue, Convert.ToInt32(tbxPostCode.Text)),
                    userPassword  = password,
                    userAdmin     = true,
                    userActive    = true
                };

                // Add admin account
                BLUser.addUser(newUser);

                // View saying verification email has been sent
                Response.Redirect("~/UL/SuccessPage/0");
            }
        }
Пример #17
0
 private void StergereClientToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (filled)
     {
         if (dataGridViewClienti.SelectedRows.Count > 0)
         {
             int        clientId  = -2;
             BLClients  blClients = new BLClients();
             BLAddress  bLAddress = new BLAddress();
             BLInvoices blInvoice = new BLInvoices();
             foreach (DataGridViewRow row in dataGridViewClienti.SelectedRows)
             {
                 clientId = Convert.ToInt32(row.Cells[0].Value.ToString());
             }
             DataTable facturiClient = blInvoice.GetInvoicesById(clientId);
             if (facturiClient.Rows.Count <= 0)
             {
                 DialogResult dialogResult = MessageBox.Show("Sigur doriti sa stergeti datele clientului?",
                                                             "Stergere Client", MessageBoxButtons.YesNo);
                 if (dialogResult == DialogResult.Yes)
                 {
                     bLAddress.DeleteAllAddresses(clientId, out string errorMessage);
                     blClients.DeleteClient(clientId, out string message);
                     MessageBox.Show(message, "Status", MessageBoxButtons.OK,
                                     MessageBoxIcon.Information);
                     initializareDataGridView();
                 }
                 else if (dialogResult == DialogResult.No)
                 {
                     this.Hide();
                 }
             }
             else
             {
                 MessageBox.Show("Nu se poate sterge clientul, deoarece are facturi inregistrate!", "Status", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
                 initializareDataGridView();
             }
         }
         else
         {
             MessageBox.Show("Selectati un client pentru stergere!", "Status", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Lista clieti goala! Efectuati o cautare!", "Status", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
 public void initFactura(InvoiceModel factura)
 {
     try
     {
         BLAddress adr        = new BLAddress();
         DataTable adresaFact = adr.GetClientAddresses(factura.client.ClientId);
         tbDatFactura.Text = factura.InvoiceDate.ToString();
         tbNrFactura.Text  = factura.InvoiceNumber.ToString();
         tbNumeClient.Text = factura.client.Nume.ToString();
     }
     catch (Exception ex)
     {
         Console.WriteLine("eroare INIT FACTURA! " + ex.Message);
     }
 }
        public void InitForm(InvoiceModel factura)
        {
            BLAddress blAdresa = new BLAddress();
            BLClients blClient = new BLClients();
            DataTable adresa   = new DataTable();
            DataTable client   = new DataTable();

            initComboBoxes();
            tbNumar.Text = factura.InvoiceNumber.ToString();
            dateTimePickerFactura.Value = factura.InvoiceDate;
            client        = blClient.GetClientById(factura.client.ClientId);
            cbClient.Text = client.Rows[0]["NumeClient"].ToString();
            adresa        = blAdresa.GetClientAddressesById(factura.client.ClientId, factura.adresa.PartnerAddressId);
            cbAdrese.Text = adresa.Rows[0]["AdresaClient"].ToString();
            tbObs.Text    = factura.Observations.ToString();
        }
Пример #20
0
        // Performs the submission of updated account settings
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                BLUser currentUser = Session["CurrentUser"] as BLUser;

                // Fills the hidden address section
                if (cbxPostageSame.Checked && !currentUser.userAdmin)
                {
                    tbxPostAddress.Text        = tbxBillAddress.Text;
                    tbxPostSuburb.Text         = tbxBillSuburb.Text;
                    ddlPostState.SelectedIndex = ddlBillState.SelectedIndex;
                    tbxPostPostCode.Text       = tbxBillPostCode.Text;
                }

                string billPostCode = currentUser.userAdmin ? "0" : tbxBillPostCode.Text;

                BLUser user = new BLUser
                {
                    userID        = currentUser.userID,
                    userFirstName = tbxFirstName.Text,
                    userLastName  = tbxLastName.Text,
                    userEmail     = tbxEmail.Text,
                    userPhone     = tbxPhone.Text,
                    billAddress   = BLAddress.fillAddress('B', tbxBillAddress.Text, tbxBillSuburb.Text, ddlBillState.SelectedValue, Convert.ToInt32(billPostCode)),
                    postAddress   = BLAddress.fillAddress('P', tbxPostAddress.Text, tbxPostSuburb.Text, ddlPostState.SelectedValue, Convert.ToInt32(tbxPostPostCode.Text)),
                    userAdmin     = currentUser.userAdmin,
                    userActive    = currentUser.userActive
                };

                if (BLUser.updateUser(user))
                {
                    Session["Name"]        = user.userFirstName;
                    Session["CurrentUser"] = user;
                    Session["UserName"]    = user.userEmail;

                    Response.Redirect("~/UL/SuccessPage/4");
                }
                else
                {
                    Response.Redirect("~/UL/ErrorPage/9");
                }

                Response.Redirect("~/UL/AccountSettings");
            }
        }
Пример #21
0
        private void CacheCurrentAddress()
        {
            cachedAddress      = new BLAddress();
            cachedAddress.Data = new Address();

            cachedAddress.Data.Key         = currentAddress.Data.Key;
            cachedAddress.SalesTaxKey      = currentAddress.SalesTaxKey;
            cachedAddress.Zip5             = currentAddress.Zip5;
            cachedAddress.Zip4             = currentAddress.Zip4;
            cachedAddress.Type             = currentAddress.Type;
            cachedAddress.Data.Name        = currentAddress.Data.Name;
            cachedAddress.Data.Line1       = currentAddress.Data.Line1;
            cachedAddress.Data.Line2       = currentAddress.Data.Line2;
            cachedAddress.Data.City        = currentAddress.Data.City;
            cachedAddress.Data.State       = currentAddress.Data.State;
            cachedAddress.Data.Zip         = currentAddress.Data.Zip;
            cachedAddress.Data.Residential = currentAddress.Data.Residential;
        }
Пример #22
0
        private void BtnAddAddress_Click(object sender, EventArgs e)
        {
            CityModel   city   = (CityModel)cmbCityName.SelectedItem;
            CountyModel county = (CountyModel)cmbCountyName.SelectedItem;
            //cmbCityName.SelectedItem.
            //MessageBox.Show(city.CityId.ToString());
            int       clientId   = id;
            int       cityId     = city.CityId;
            int       countyId   = county.CountyId;
            string    cityName   = city.CityName;
            string    countyName = county.CountyName;
            string    streetName = txtStreetName.Text;
            string    streetNo   = txtStreetNo.Text;
            BLAddress bl         = new BLAddress();

            parent.RefreshGridAdd(bl.GetAddress(-1, cityName, countyName, streetName, streetNo));
            //bl.AddAddress(clientId, cityId, countyId, streetName, streetNo);
            //MessageBox.Show("Adresa a fost adaugata cu succes.");
        }
Пример #23
0
        public AddAddressForm(int _id, ClientAddressForm owner)
        {
            id     = _id;
            parent = owner;
            InitializeComponent();
            BLAddress          bLAddress = new BLAddress();
            List <CityModel>   cities    = bLAddress.GetCity();
            List <CountyModel> county    = bLAddress.GetCounty();


            cmbCountyName.DataSource    = county;
            cmbCountyName.DisplayMember = "CountyName";

            //cmbCountyName.ValueMember.


            cmbCityName.DataSource    = cities;
            cmbCityName.DisplayMember = "CityName";
        }
        public UpdateAddressForm(int _clientId, int _clientAddressId, ClientAddressForm owner)
        {
            clientIdValue        = _clientId;
            clientAddressIdValue = _clientAddressId;
            parent = owner;
            InitializeComponent();
            BLAddress          bLAddress = new BLAddress();
            List <CityModel>   cities    = bLAddress.GetCity();
            List <CountyModel> county    = bLAddress.GetCounty();


            cmbCounty.DataSource    = county;
            cmbCounty.DisplayMember = "CountyName";
            cmbCounty.SelectedIndex = -1;



            cmbCity.DataSource    = cities;
            cmbCity.DisplayMember = "CityName";
            cmbCity.SelectedIndex = -1;
        }
Пример #25
0
        // Submission of registration form
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (cbxPostageSame.Checked)
            {
                tbxPostAddress.Text        = tbxBillAddress.Text;
                tbxPostSuburb.Text         = tbxBillSuburb.Text;
                ddlPostState.SelectedIndex = ddlBillState.SelectedIndex;
                tbxPostPostCode.Text       = tbxBillPostCode.Text;
            }
            // Redirect if form submission was valid
            if (IsValid)
            {
                BLUser newUser = new BLUser
                {
                    userFirstName = tbxFirstName.Text,
                    userLastName  = tbxLastName.Text,
                    userEmail     = tbxEmail.Text,
                    userPhone     = tbxPhone.Text,
                    billAddress   = BLAddress.fillAddress('B', tbxBillAddress.Text, tbxBillSuburb.Text, ddlBillState.SelectedValue, Convert.ToInt32(tbxBillPostCode.Text)),
                    postAddress   = BLAddress.fillAddress('P', tbxPostAddress.Text, tbxPostSuburb.Text, ddlPostState.SelectedValue, Convert.ToInt32(tbxPostPostCode.Text)),
                    userPassword  = tbxPassword.Text,
                    userAdmin     = false,
                    userActive    = true
                };

                BLUser.addUser(newUser);

                newUser.login(newUser.userEmail, newUser.userPassword);

                Session["CurrentUser"] = newUser;
                Session["UserName"]    = newUser.userEmail;
                Session["Name"]        = newUser.userFirstName;
                Session["LoginStatus"] = "User";

                Response.Redirect("~/UL/Default");
            }
        }
Пример #26
0
        //--------------NEW-----------------
        private void btnNew_Click(object sender, EventArgs e)
        {
            bool proceed = NotifyIfAddressIsDirty();

            if (proceed)
            {
                currentAddress      = new BLAddress();
                currentAddress.Data = new Address();
                currentCustAddress  = new CustAddress();

                addressControl.ClearForm();
                txtTaxRate.Clear();
                statusLabel.Text = string.Empty;

                UnsubscribeFromCheckChanged();
                chkPrimaryBilling.Checked = false;
                chkShipping.Checked       = false;
                chkCommon.Checked         = true;
                rdoActive.Checked         = true;
                rdoActive.Enabled         = false;
                rdoDeleted.Enabled        = false;
                SubscribeToCheckChanged();
            }
        }
        //CONTROL LOAD
        private void BillingAndShippingAddressControl_Load(object sender, EventArgs e)
        {
            address = new BLAddress(new TaxService(), new ValidationService());

            address.IsSameAsPrimary = AddrSameAsPrimary;
            address.IsValidated     = address.IsSameAsPrimary;

            if (address.IsSameAsPrimary)
            {
                MapAddressToBLAddress(PrimaryAddress, address, "Primary");
            }
            else
            {
                MapAddressToBLAddress(Address, address, "Billing");
            }

            loading = true;
            chkSameAsPrim.Checked = address.IsSameAsPrimary;
            loading = false;

            CreateAddressControlForBilling();

            Done(address);
        }
        private void QualifySingleAddress(ref BLAddress addr, Customer customer)
        {
            string type = addr.Type == null ? "" : addr.Type;

            if (customer != null && string.IsNullOrEmpty(type))
            {
                if (addr.Data.Key == customer.DfltShipToAddrKey)
                {
                    type = type.Insert(0, "Ship");
                    addr.IsDefaultShipping = true;
                }
                else
                {
                    addr.IsDefaultShipping = false;
                }

                if (addr.Data.Key == customer.DfltBillToAddrKey)
                {
                    type = type.Insert(0, "Bill");
                    addr.IsPrimaryAddress = true;
                    addr.IsDefaultBilling = true;
                }
                else
                {
                    addr.IsDefaultBilling = false;
                    addr.IsPrimaryAddress = false;
                }

                if (type.Length == 0)
                {
                    type = "CSA";
                }

                addr.Type = type;
            }
        }
        public void Save(int id)
        {
            BLClient bl = new BLClient();

            if (id != 0)
            {
                List <ClientModule> listUpdate = bl.GetClientList(id, "", "", "", "", "");
                ClientModule        client     = listUpdate[0];
                string clientName    = txtClientName.Text;
                string clientSurname = txtClientSurname.Text;
                string clientCode    = txtClientCode.Text;
                string email         = txtEmail.Text;
                string phoneNo       = txtPhoneNo.Text;

                if (!(clientName == client.ClientName & clientSurname == client.ClientSurname & clientCode == client.ClientCode & email == client.Email & phoneNo == client.PhoneNo))
                {
                    foreach (char c in txtPhoneNo.Text.ToCharArray())
                    {
                        if (!(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9'))
                        {
                            MessageBox.Show("Tnumarul de telefon trebuie sa contina doar cife.", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                    if (!(new EmailAddressAttribute().IsValid(txtEmail.Text)) & !String.IsNullOrWhiteSpace(txtEmail.Text))
                    {
                        MessageBox.Show("Emailul trebuie sa fie valid!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }


                    //txtClientCode.TextChanged
                    bool status = false;
                    if (clientCode == client.ClientCode)
                    {
                        bl.UpdateClient(id, clientName, clientSurname, "", phoneNo, email, out status);
                    }
                    else
                    {
                        bl.UpdateClient(id, clientName, clientSurname, clientCode, phoneNo, email, out status);
                    }
                    //BLClient bl = new BLClient();

                    if (status)
                    {
                        MessageBox.Show("Modificare reusita.");
                    }
                    else
                    {
                        MessageBox.Show("Codul de client exista deja!");
                        return;
                    }
                }



                BLAddress bLAddress = new BLAddress();
                //List<AddressModel> list= new List<AddressModel>();
                //list = bLAddress.Address(id);
                for (int i = 0; i < dataGridClientAddress.Rows.Count; i++)
                {
                    AddressModel addressModel = new AddressModel();
                    addressModel = (AddressModel)dataGridClientAddress.Rows[i].DataBoundItem;
                    if (addressModel.status == 1)
                    {
                        bLAddress.AddAddress(id, addressModel.CityName, addressModel.CountyName, addressModel.StreetName, addressModel.StreetNo);
                    }
                    //INSERT
                    if (addressModel.status == 2)
                    {
                        bLAddress.UpdateAddress(id, addressModel.ClientAddressId, addressModel.CityName, addressModel.CountyName, addressModel.StreetName, addressModel.StreetNo);
                    }



                    //UPDATE
                    if (addressModel.status == 3)
                    {
                        bLAddress.DeleteAddress(addressModel.ClientId, addressModel.ClientAddressId);
                    }
                }
            }
            else
            {
                if (String.IsNullOrWhiteSpace(txtClientName.Text))
                {
                    MessageBox.Show("Numele clientului este obligatoriu", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (String.IsNullOrWhiteSpace(txtClientSurname.Text))
                {
                    MessageBox.Show("Prenumele utilizatorului eate obligatoriu", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (String.IsNullOrWhiteSpace(txtClientCode.Text))
                {
                    MessageBox.Show("codul de client este obligatoriu", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                foreach (char c in txtPhoneNo.Text.ToCharArray())
                {
                    if (!(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9'))
                    {
                        MessageBox.Show("Numarul de telefon trebuie sa contina doar cife.", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                if (!(new EmailAddressAttribute().IsValid(txtEmail.Text)) & !String.IsNullOrWhiteSpace(txtEmail.Text))
                {
                    MessageBox.Show("Emailul trebuie sa fie valid!", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string clientName    = txtClientName.Text;
                string clientSurname = txtClientSurname.Text;
                string clientCode    = txtClientCode.Text;
                string phoneNo       = String.IsNullOrWhiteSpace(txtPhoneNo.Text) ? null : txtPhoneNo.Text;
                string email         = String.IsNullOrWhiteSpace(txtEmail.Text) ? null : txtEmail.Text;;
                bool   status        = true;

                bl.AddClient(clientName, clientSurname, clientCode, phoneNo, email, out status);
                if (status)
                {
                    MessageBox.Show("Clientul " + clientName + " " + clientSurname + " a fost adaugat cu succes");
                    List <ClientModule> list = bl.GetClientList(-1, "", "", clientCode, "", "");
                    Save(list[0].ClientId);//RECURSIVITATE
                }
                //MessageBox.Show("Clientul " + clientName + " " + clientSurname + " a fost adaugat cu succes");
                else
                {
                    MessageBox.Show("Codul de client exista deja!");
                }
            }
        }
Пример #30
0
    public void Retrieve()
    {
        DataSet dsitems;

            if( this.uid.Length > 0 )
                dsitems = DALCCustomer.GetItemBySessionID(this.uid);
         			else
                dsitems = DALCCustomer.GetItem(this.id);

            if( dsitems.Tables.Count > 0 && dsitems.Tables[0].Rows.Count > 0)
            {
                this.id = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["ID"] );
                this.uid = Convert.ToString( dsitems.Tables["Customer"].Rows[0]["SessionID"] );
                this.created = Convert.ToDateTime( dsitems.Tables["Customer"].Rows[0]["Created"] );
                this.saveInfo = Convert.ToBoolean( dsitems.Tables["Customer"].Rows[0]["SaveInfo"] );

                int creditCardID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["CreditCardInfoID"] );
                int billingInfoID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["BillingAddressID"] );
                int shippingInfoID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["ShippingAddressID"] );

                if (organization == null)
                {
                    organization = new BLOrganization();
                }

                if( creditCardID > 0)
                {
                    creditCard = new BLCreditCard();
                    creditCard.ID = creditCardID;
                    creditCard.Retrieve();
                }

                if( billingInfoID > 0 )
                {
                    billingAddress = new BLAddress();
                    billingAddress.ID = billingInfoID;
                    billingAddress.Retrieve();
                }

                if( shippingInfoID > 0 )
                {
                    shippingAddress = new BLAddress();
                    shippingAddress.ID = shippingInfoID;
                    shippingAddress.Retrieve();
                }

                if(shoppingCart == null)
                {
                    shoppingCart = new BLShoppingCart();
                }

                shoppingCart.CustomerID = this.id;
                shoppingCart.Retrieve();

                if(organization == null)
                {
                    organization = new  BLOrganization();
                }

                ///////////organization.ID  = messages.orgID;
                organization.Retrieve();/// = new BLShoppingCart();

               /// messages.cust = this ;

               /// messages.org = organization;

            }
            else
            {
                this.id = 0;
                ClearFields();
            }
    }
Пример #31
0
    private void ClearFields()
    {
        this.created = DateTime.MinValue;
            this.uid = string.Empty;
            this.saveInfo = false;

            this.creditCard = null;
            this.billingAddress = null;
            this.shippingAddress = null;
            this.shoppingCart = null;

            this.billingAddress = new BLAddress();
            this.shippingAddress = new BLAddress();
            this.shoppingCart = new BLShoppingCart();
            this.creditCard = new BLCreditCard();
            this.organization = new BLOrganization();
            this.organizationhld = new BLOrganization();
    }
Пример #32
0
    private void ClearFields()
    {
        this.created = DateTime.MinValue;
            this.uid = string.Empty;
            this.saveInfo = false;

            this.creditCard = null;
            this.billingAddress = null;
            this.shippingAddress = null;
            this.shoppingCart = null;
            this.category = null;

            this.billingAddress = new BLAddress();
            this.shippingAddress = new BLAddress();
            this.shoppingCart = new BLShoppingCart();
            this.creditCard = new BLCreditCard();
            this.items = new BLItems();
            this.orders = new BLOrders();
            this.category = new BLCategory();
            this.item = new BLItem();
    }
Пример #33
0
    public void Retrieve()
    {
        DataSet dsitems;

        ////////////////////  dsitems=  GetOrgList( , "S", "get_Orgs", this.ID, "");

         dsKnow =   r.get_orgKnow("get_orgKnow", "S", this.ID, "");

            if( this.uid.Length > 0 )
                dsitems = DALCCustomer.GetItemBySessionID(this.uid);
         			else
                dsitems = DALCCustomer.GetItem(this.id);

            if( dsitems.Tables.Count > 0 && dsitems.Tables[0].Rows.Count > 0)
            {
                this.id = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["ID"] );
                this.uid = Convert.ToString( dsitems.Tables["Customer"].Rows[0]["SessionID"] );
                this.created = Convert.ToDateTime( dsitems.Tables["Customer"].Rows[0]["Created"] );
                this.saveInfo = Convert.ToBoolean( dsitems.Tables["Customer"].Rows[0]["SaveInfo"] );

                int creditCardID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["CreditCardInfoID"] );
                int billingInfoID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["BillingAddressID"] );
                int shippingInfoID = Convert.ToInt32( dsitems.Tables["Customer"].Rows[0]["ShippingAddressID"] );

                if( creditCardID > 0)
                {
                    creditCard = new BLCreditCard();
                    creditCard.ID = creditCardID;
                    creditCard.Retrieve();
                }

                if( billingInfoID > 0 )
                {
                    billingAddress = new BLAddress();
                    billingAddress.ID = billingInfoID;
                    billingAddress.Retrieve();
                }

                if( shippingInfoID > 0 )
                {
                    shippingAddress = new BLAddress();
                    shippingAddress.ID = shippingInfoID;
                    shippingAddress.Retrieve();
                }

                if (shoppingCart == null)
                {
                    shoppingCart = new BLShoppingCart();
                }

                shoppingCart.CustomerID = this.id;
                shoppingCart.Retrieve();

                if(items == null)
                {
                     items = new BLItems();
                }
                 items.OrgID = this.id;
                items.Retrieve();

            }
            else
            {
                this.id = 0;
                ClearFields();
            }
    }
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            bool searchingByPhone = txtZipCode.Text == "";

            if (searchingByPhone)
            {
                Cursor = Cursors.WaitCursor;

                var service   = new CustomerService();
                var customers = service.GetCustomersByPhone(txtPhone.Text);

                var addresses = new List <BLAddress>();

                foreach (var currentCustomer in customers)
                {
                    var currentAddresses = new List <BLAddress>();

                    foreach (var custAddr in currentCustomer.CustAddresses)
                    {
                        if (custAddr.ShipDays < 90)
                        {
                            currentAddresses.Add(new BLAddress {
                                Data = custAddr.Address, CustId = currentCustomer.Id
                            });
                        }
                    }

                    addresses.AddRange(await QualifyAddressesAsync(currentAddresses, currentCustomer));
                }

                addresses = addresses
                            .OrderBy(c => c.CustId)
                            .ThenByDescending(c => c.IsPrimaryAddress)
                            .ThenByDescending(c => c.IsDefaultShipping)
                            .ThenBy(c => c.Data.Line1).ToList();

                SetUpDataGrid(addresses);
                SetCountLabel(addresses.Count);

                Cursor = Cursors.Arrow;
            }
            else
            {
                Cursor = Cursors.WaitCursor;

                var service   = new CustomerService();
                var addresses = await service.GetAddressesByZipCodeAsync(txtZipCode.Text.TrimEnd());

                var blAddresses = new List <BLAddress>();

                foreach (var address in addresses)
                {
                    if (address.CustAddress == null)
                    {
                        continue;
                    }
                    if (address.CustAddress.ShipDays > 90)
                    {
                        continue;
                    }

                    var customer = address.CustAddress.Customer;

                    var currentAddress = new BLAddress {
                        Data = address, CustId = customer.Id
                    };

                    QualifySingleAddress(ref currentAddress, customer);

                    blAddresses.Add(currentAddress);
                }

                blAddresses = blAddresses
                              .OrderBy(c => c.CustId)
                              .ThenByDescending(c => c.IsPrimaryAddress)
                              .ThenByDescending(c => c.IsDefaultShipping)
                              .ThenBy(c => c.Data.Line1).ToList();

                SetUpDataGrid(blAddresses);
                SetCountLabel(blAddresses.Count);

                Cursor = Cursors.Arrow;
            }
        }