Пример #1
0
        private void AddVendorButton_Click(object sender, EventArgs e)
        {
            string nameOfVendorToAdd = VendorNameTextBox.Text;
            string nameOfItem        = VendorItemComboBox.GetItemText(this.VendorItemComboBox.SelectedItem);
            bool   result            = Vendor.AddVendor(nameOfVendorToAdd, nameOfItem);

            if (!result)
            {
                MessageBox.Show("Item specified already exists");
            }

            updateAllDatatable();
        }
Пример #2
0
        private void btnSaveVendor_Click(object sender, EventArgs e)
        {
            int addressid = 0;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    Address add  = new Address();
                    Vendor  vend = new Vendor();

                    add.AddressLine1  = dataGridView1.Rows[i].Cells["address 2"].Value.ToString();
                    add.AddressLine2  = dataGridView1.Rows[i].Cells["addresline2"].Value.ToString();
                    add.City          = dataGridView1.Rows[i].Cells["city"].Value.ToString();
                    add.StateProvince = dataGridView1.Rows[i].Cells["state"].Value.ToString();
                    add.PostalCode    = dataGridView1.Rows[i].Cells["zip"].Value.ToString();
                    addressid         = add.AddAddress(add);

                    vend.AccountNumber = "";
                    vend.AddressID     = addressid;
                    vend.ActiveFlag    = true;
                    //vend.ContactName = dataGridView1.Rows[i].Cells["FirstName"].Value.ToString();
                    vend.CreditRating          = 100;
                    vend.Email                 = dataGridView1.Rows[i].Cells["alt phone"].Value.ToString();
                    vend.Phone                 = dataGridView1.Rows[i].Cells["contact"].Value.ToString();
                    vend.Fax                   = dataGridView1.Rows[i].Cells["phone"].Value.ToString();
                    vend.ModifiedDate          = DateTime.Now;
                    vend.Name                  = dataGridView1.Rows[i].Cells["vendor"].Value.ToString();
                    vend.ContactName           = dataGridView1.Rows[i].Cells["firstname"].Value.ToString() + " " + dataGridView1.Rows[i].Cells["MI"].Value.ToString() + " " + dataGridView1.Rows[i].Cells["lastname"].Value.ToString();
                    vend.PreferredVendorStatus = true;
                    vend.AddVendor(vend);
                    add  = null;
                    vend = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsInvalidControl())
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            Vendor  v      = new Vendor();
            Vendor  vendor = new Vendor();
            Address add    = new Address();

            try
            {
                v.Name = txtName.Text.Trim();

                v.ContactName   = txtContactName.Text.Trim();
                v.AccountNumber = txtAccountNumber.Text.Trim();
                if (txtCreditRating.Text.Trim().Length > 0)
                {
                    v.CreditRating = Byte.Parse(txtCreditRating.Text.Trim());
                }
                else
                {
                    v.CreditRating = 0;
                }
                v.ActiveFlag            = chkActive.Checked;
                v.Phone                 = txtPhone.Text.Trim();
                v.AltPhone              = txtPhone.Text;
                v.Terms                 = txtTerms.Text;
                v.Fax                   = txtFax.Text.Trim();
                v.Email                 = txtEmail.Text.Trim();
                v.PreferredVendorStatus = chkPrefered.Checked;
                v.ModifiedDate          = DateTime.Now;
                add.AddressLine1        = txtStreetAddress.Text;
                add.City                = txtCity.Text;
                add.StateProvince       = txtState.Text;
                add.PostalCode          = txtZip.Text;
                int vendid = v.Exists(v.Name);
                if (vendid > 0)
                {
                    DialogResult result = MessageBox.Show("Vendor: " + v.Name + " already exists\nWould you like to update it?", "MICS", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        v.VendorID = vendid;
                        v.UpdateVendor(v);
                        int vendAddressId = v.AddressID;
                        add.UpdateAddress(add);
                        PopulateGrid(v.VendorID);
                        MessageBox.Show("Record updated successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Record is not saved", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    return;
                }
                v.AddressID     = add.AddAddress(add);
                vendor.VendorID = vendor.AddVendor(v);
                PopulateGrid(vendor.VendorID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                vendor = null;
                v      = null;
            }
            Cursor.Current = Cursors.Default;
        }