Ejemplo n.º 1
0
 public bool AddItem(string CShortName)
 {
     if (CustExists(CShortName))
     {
         return false;
     }
     else
     {
         Customer c = new Customer(CShortName);
         cList.Add(c);
         return true;
     }
 }
Ejemplo n.º 2
0
        public static Customer PopulateCustomersFromSqlDataReader(SqlDataReader dr)
        {
            Customer cust = new Customer();

            cust.ID = Convert.ToInt32(dr["ID"]);
            cust.CustShortName = Convert.ToString(dr["CUSTSHORTNAME"]);
            cust.CustName =  Convert.ToString(dr["CUSTNAME"]);
            cust.ContactName =  Convert.ToString(dr["CONTACTNAME"]);
            cust.Phone1 =  Convert.ToString(dr["PHONE1"]);
            cust.Phone2 =  Convert.ToString(dr["PHONE2"]);
            cust.Fax=  Convert.ToString(dr["FAX"]);
            cust.Email =  Convert.ToString(dr["EMAIL"]);

            return cust;
        }
Ejemplo n.º 3
0
        private void button28_Click(object sender, EventArgs e)
        {
            //Delete Customer
            if (CustIDcombo.Text != "")
            {
                DialogResult result = MessageBox.Show("Are you sure you want to delete the current Customer? " +
                    "Doing so will also perminately delete the Customer from the database.",
                    "Delete Customer?",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2,
                    MessageBoxOptions.DefaultDesktopOnly,
                    false);

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        Customer c1 = new Customer();
                        c1 = CustList.SearchCustomer(CustIDcombo.Text);
                        DeleteAllBillShip(c1.ID);
                        CustList.DeleteCust(CustIDcombo.Text);
                        CustIDcombo.DataSource = CustList.ListCustomers();

                        if (CustIDcombo.Items.Count == 0)
                        {
                            textBox24.Text = "";
                            textBox5.Text = "";
                            textBox19.Text = "";
                            textBox100.Text = "";
                            textBox101.Text = "";
                            textBox103.Text = "";
                            CustIDcombo.Text = "";
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void AddCustomer(Customer Cust)
        {
            // Initialize SPROC

            SqlConnection conn = new SqlConnection(ConnectionString);
            SqlCommand cmd = new SqlCommand("SPCustInsert", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            // Add Parameters

            cmd.Parameters.AddWithValue("@CUSTSHORTNAME", Cust.CustShortName );
            cmd.Parameters.AddWithValue("@CUSTNAME", Cust.CustName);
            cmd.Parameters.AddWithValue("@CONTACTNAME",Cust.ContactName);
            cmd.Parameters.AddWithValue("@PHONE1", Cust.Phone1);
            cmd.Parameters.AddWithValue("@PHONE2", Cust.Phone2);
            cmd.Parameters.AddWithValue("@FAX", Cust.Fax );
            cmd.Parameters.AddWithValue("@EMAIL", Cust.Email);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
            reload();
        }
Ejemplo n.º 5
0
 public Customer SearchCustomer(string CShortName)
 {
     foreach (Customer cust in cList)
     {
         if (cust.CustShortName == CShortName)
         {
             return (cust);
         }
     }
     Customer c = new Customer(CShortName);
     return (c);
 }
Ejemplo n.º 6
0
 private void Object2Form(Customer c)
 {
     int Index = CustIDcombo.FindString(c.CustShortName);
     CustIDcombo.SelectedIndex = Index;
     textBox24.Text = c.CustName;
     textBox5.Text = c.Phone1;
     textBox19.Text =c.Phone2;
     textBox100.Text = c.Fax;
     textBox101.Text = c.Email;
     textBox103.Text = c.ContactName;
     LoadBillShip(c.ID);
 }
Ejemplo n.º 7
0
 private Customer Form2Object()
 {
     Customer tCust = new Customer(0, CustIDcombo.Text, textBox24.Text, textBox5.Text, textBox19.Text, textBox100.Text, textBox101.Text, textBox103.Text);
     return tCust;
 }
Ejemplo n.º 8
0
        //Delete A Shipping Address
        private void button70_Click(object sender, EventArgs e)
        {
            // Delete Address
            if (dataGridView5.SelectedCells.Count > 0)
            {

                DialogResult result = MessageBox.Show("Are you sure you want to delete the current Address? " +
                    "Doing so will also delete the  selected BillTo or ShipTo Address.",
                    "Delete Address?",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2,
                    MessageBoxOptions.DefaultDesktopOnly,
                    false);

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        string strAddrName;
                        string strAddrType;

                        strAddrName = dataGridView5.SelectedCells[0].Value.ToString();
                        strAddrType = dataGridView5.SelectedCells[1].Value.ToString();
                        Customer c1 = new Customer();
                        c1 = CustList.SearchCustomer(CustIDcombo.Text);
                        BillShipList cBSList = new BillShipList(c1.ID);
                        cBSList.DeleteCustBillShip(cBSList.SearchBillShip(strAddrName, strAddrType).ID);
                        LoadBillShip(c1.ID);
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                }
            }
        }