Esempio n. 1
0
        public suppliers[] GetSupplierNameOnly() //returns supplier names
        {
            DataSet   ds     = new DataSet();
            ArrayList sup    = new ArrayList();
            string    cmdStr = "Select Name From [suppliers]";

            using (OleDbCommand command = new OleDbCommand(cmdStr))
            {
                ds = GetMultipleQuery(command);
            }

            DataTable dt = new DataTable();

            try
            {
                dt = ds.Tables[0];
            }
            catch { }
            foreach (DataRow tType in dt.Rows)
            {
                suppliers Name = new suppliers();

                Name.Sup_name = tType[0].ToString();

                sup.Add(Name);
            }
            return((suppliers[])sup.ToArray(typeof(suppliers)));
        }
Esempio n. 2
0
        public suppliers[] getAllsuppliers() //returns all the suppliers in the table
        {
            DataSet   ds      = new DataSet();
            ArrayList supparr = new ArrayList();
            string    cmdStr  = "SELECT * FROM suppliers";

            using (OleDbCommand command = new OleDbCommand(cmdStr))
            {
                ds = GetMultipleQuery(command);
            }

            DataTable dt = new DataTable();

            try
            {
                dt = ds.Tables[0];
            }
            catch
            {
            }
            foreach (DataRow tType in dt.Rows)
            {
                suppliers supp = new suppliers();

                supp.Supplier_id = int.Parse(tType[0].ToString());
                supp.Sup_name    = tType[1].ToString();
                supp.Address     = tType[2].ToString();
                supp.Phone       = int.Parse(tType[3].ToString());
                supp.Email       = tType[4].ToString();


                supparr.Add(supp);
            }
            return((suppliers[])supparr.ToArray(typeof(suppliers)));
        }
Esempio n. 3
0
        private void btnUpdateSupplier_Click(object sender, EventArgs e) //button to update supplier
        {
            if (!string.IsNullOrEmpty(txtUpdateSupplierId.Text))
            {
                suppliers sup = new suppliers();

                sup.Sup_name    = UpdateSupplierNametxt.Text;
                sup.Address     = txtUpdateSupplierAddr.Text;
                sup.Phone       = int.Parse(txtUpdateSupplierPhone.Text);
                sup.Supplier_id = int.Parse(txtUpdateSupplierId.Text);
                sup.Email       = txtUpdateSupplierEmail.Text;

                try
                {
                    dataB.UpdateSupplier(sup);
                    MessageBox.Show("Success the SUPPLIER is Updated");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Supplier ID is empty!! make sure to fill it.");
            }
        }
Esempio n. 4
0
        public void UpdateSupplier(suppliers sup) //updates supplier in the table
        {
            string cmdStr = "UPDATE [suppliers] SET name=@Sup_name,address=@Address,phone=@Phone,email=@Email WHERE supplier_id =" + sup.Supplier_id;

            using (OleDbCommand command = new OleDbCommand(cmdStr))
            {
                command.Parameters.AddWithValue("@name", sup.Sup_name);
                command.Parameters.AddWithValue("@address", sup.Address);
                command.Parameters.AddWithValue("@phone", sup.Phone);
                command.Parameters.AddWithValue("@email", sup.Email);

                base.ExecuteSimpleQuery(command);
            }
        }
Esempio n. 5
0
        // ****** SUPPLIERS ******
        public void InsertSupplier(suppliers sup) //insert Supplier to the table
        {
            string cmdStr = "INSERT INTO [suppliers] (name,Address,phone,email) VALUES(@Name,@Address,@phone,@email)";

            using (OleDbCommand command = new OleDbCommand(cmdStr))
            {
                command.Parameters.AddWithValue("@Name", sup.Sup_name);
                command.Parameters.AddWithValue("@Address", sup.Address);
                command.Parameters.AddWithValue("@phone", sup.Phone);
                command.Parameters.AddWithValue("@email", sup.Email);

                base.ExecuteSimpleQuery(command);
            }
        }
Esempio n. 6
0
 private void btnAddSupplier_Click(object sender, EventArgs e) //button to add supplier
 {
     if (!string.IsNullOrWhiteSpace(AddSupplierAddresstxt.Text) && !string.IsNullOrWhiteSpace(AddSupplierNametxt.Text) && !string.IsNullOrWhiteSpace(supplierphonetxt.Text) && !string.IsNullOrWhiteSpace(supplieremailtxt.Text))
     {
         suppliers sup = new suppliers();
         sup.Address  = AddSupplierAddresstxt.Text;
         sup.Sup_name = AddSupplierNametxt.Text;
         sup.Email    = supplieremailtxt.Text;
         sup.Phone    = int.Parse(supplierphonetxt.Text);
         try
         {
             dataB.InsertSupplier(sup);
             MessageBox.Show("The Supplier Have Been Sucessfully Inserted");
         }
         catch (Exception)
         {
             MessageBox.Show("Supplier Name Already Exists");
         }
     }
     else
     {
         MessageBox.Show("One Or More Field Is Empty");
     }
 }