private void ViewSOrder_Load(object sender, EventArgs e)
        {
            DBSales        s = new DBSales();
            SqlDataAdapter da;

            da = s.getSalesOrders();
            DataTable dt = new DataTable();

            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
Beispiel #2
0
        private void mtadd_Click_1(object sender, EventArgs e)
        {
            int     flag = 1, error = 0;
            String  date   = txtdate.Text;
            String  status = txtstatus.Text;
            DBSales ds     = new DBSales();

            if (txtqty.Text.Length == 0 && txtprice.Text.Length == 0 && txtstatus.Text.Length == 0)
            {
                MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                error = 1;
            }
            if (txtprice.Text.Any(Char.IsLetter))
            {
                MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                error = 1;
            }
            if (txtqty.Text.Any(Char.IsLetter))
            {
                error = 1;
                MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbitemname.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (error == 1)
            {
                MessageBox.Show("Check if all the fields are filled correctly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            else
            {
                int so_no = ds.setSalesOrder(date, status, count_tot, count_qty, u_id, no);
                DBSales_Item_reference S_I_ref = new DBSales_Item_reference();
                foreach (DataGridViewRow Datarow in dataGridView1.Rows)
                {
                    if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null)
                    {
                        String itemName = dataGridView1.CurrentRow.Cells["itemName"].Value.ToString();
                        int    itemqty  = Convert.ToInt32(dataGridView1.CurrentRow.Cells["itemQty"].Value);
                        int    itemtot  = Convert.ToInt32(dataGridView1.CurrentRow.Cells["itemPrice"].Value);

                        DBItem di     = new DBItem();
                        int    itemno = di.getItemNo(itemName);
                        S_I_ref.setReference(so_no, itemno, itemqty, itemtot);
                        di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag);
                    }
                }
            }
        }
        private void metroButton2_Click(object sender, EventArgs e)
        {
            DBCustomer c = new DBCustomer();

            cusno = c.getCusNo(cmbcusnic.SelectedItem.ToString());
            DBSales s = new DBSales();

            DR = s.getSalesOrder(cusno);
            while (DR.Read())
            {
                cmbsorder.Items.Add(Convert.ToInt32(DR[0]));
            }
        }
        private void Delivery_Load(object sender, EventArgs e)
        {
            txtdate.Text = System.DateTime.Now.ToString("MM/dd/yyyy");
            DBSales       s = new DBSales();
            SqlDataReader DR;

            DR = s.getSalesOrderID();
            while (DR.Read())
            {
                cmbsalesorder.Items.Add(DR[0]);
            }
            SqlDataAdapter da;
            DBDelivery     i = new DBDelivery();

            da = i.getDelivery();
            DataTable dt = new DataTable();

            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }