Exemplo n.º 1
0
        private void mtadd_Click(object sender, EventArgs e)
        {
            int error = 0;

            if (txtprice.Text.Length == 0 && txtstatus.Text.Length == 0 && txtqty.Text.Length == 0)
            {
                error = 1;
                MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (cmbitemname.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbsupname.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select a Supplier Name", "Ërror", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (txtprice.Text.Any(Char.IsLetter))
            {
                error = 1;
                MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (txtqty.Text.Any(Char.IsLetter))
            {
                error = 1;
                MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (error != 1)
            {
                String      date    = txtdate.Text;
                String      status  = txtstatus.Text;
                String      supname = cmbsupname.SelectedItem.ToString();
                DBSupplier  sup     = new DBSupplier();
                int         sup_no  = sup.getSupNo(supname);
                DBPurchases dp      = new DBPurchases();
                int         po_no   = dp.setPurchaseOrder(date, status, count_tot, count_qty, Users_ID, sup_no);
                DBPurchase_Item_reference P_I_ref = new DBPurchase_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["Item_Name"].Value.ToString();
                        int    itemqty  = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value);
                        int    itemtot  = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value);
                        DBItem di       = new DBItem();
                        int    itemno   = di.getItemNo(itemName);
                        P_I_ref.setReference(po_no, itemno, itemqty, itemtot);
                    }
                }
            }
        }
        private void mtAdd_Click(object sender, EventArgs e) ////// editable
        {
            int error = 0;

            if (txttotqty.Text.Length == 0 && txtprice.Text.Length == 0)
            {
                error = 1;
                MessageBox.Show("Please fill out all the fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (numQty.Value == 0)
            {
                error = 1;
                MessageBox.Show("Please select Item Quantity to return", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbporder.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select a Purchase Order Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbsupname.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select a Supplier Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (error == 0)
            {
                int              flag     = 0;
                int              PurchNo  = Convert.ToInt32(cmbporder.SelectedItem);
                String           date     = txtdate.Text;
                int              Users_ID = u_id;
                String           supname  = cmbsupname.SelectedItem.ToString();
                DBSupplier       sup      = new DBSupplier();
                int              sup_no   = sup.getSupNo(supname);
                DBPurchaseReturn dp       = new DBPurchaseReturn();
                int              pr_no    = dp.setPurchaseReturn(count_tot, count_qty, date, Users_ID, sup_no, PurchNo);
                DBPurchaseReturns_Item_reference PR_I_ref = new DBPurchaseReturns_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["Item_Name"].Value.ToString();
                        int    itemno  = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_No"].Value);
                        int    itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value);
                        int    itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value);
                        DBItem di      = new DBItem();
                        //int itemno = di.getItemNo(itemName);
                        flag = PR_I_ref.setReference(pr_no, itemno, itemqty, itemtot);
                        di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag);
                    }
                }
            }
        }
 private void metroButton2_Click(object sender, EventArgs e)
 {
     if (cmbsupname.SelectedIndex != 0)
     {
         String      name   = cmbsupname.SelectedItem.ToString();
         DBSupplier  sup    = new DBSupplier();
         int         sup_id = sup.getSupNo(name);
         DBPurchases p      = new DBPurchases();
         DR = p.selectOrder(sup_id);
         while (DR.Read())
         {
             cmbporder.Items.Add(DR[0].ToString());
         }
     }
     else
     {
         MessageBox.Show("Please select a supplier name ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void mtUpdate_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Do you want to update?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (dr.ToString() == "Yes")
            {
                if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txtstatus.Text) || txttele.Text.Length != 10)
                {
                    MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                else
                {
                    try
                    {
                        String     name   = txtname.Text;
                        String     add    = txtadd.Text;
                        String     status = txtstatus.Text;
                        int        tele   = Convert.ToInt32(txttele.Text);
                        DBSupplier di     = new DBSupplier();
                        int        no     = di.getSupNo(name);
                        int        line   = di.updateSupplier(name, add, status, tele, u_id, no);
                        if (line == 1)
                        {
                            MessageBox.Show("Data entered successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Please enter your data and try again");
                    }
                }
            }
            this.Hide();
            Suppliers s = new Suppliers();

            s.setid(u_id);
            s.Show();
        }