private void mtAdd_Click(object sender, EventArgs e)
        {
            String name;
            String add;
            int    mob;
            String status;
            int    flag = 0;

            if (txtname.Text.Any(Char.IsDigit))
            {
                flag = 1;
                MessageBox.Show("Name cannot contain digits", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            // if (txttele.Text.Length != 10)
            //{
            //  flag = 1;
            //MessageBox.Show("Wrong Telephone Number", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);

            // }
            if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txttele.Text))
            {
                flag = 1;
                MessageBox.Show("Do not keep any fields empty", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            if (flag == 0)
            {
                name   = txtname.Text;
                add    = txtadd.Text;
                mob    = Convert.ToInt32(txttele.Text);
                status = txtstatus.Text;
                DBSupplier c = new DBSupplier();
                c.setSupplier(name, add, mob, status, u_id);
            }
        }
        private void Purchase_Returns_Load(object sender, EventArgs e)
        {
            txtdate.Text = System.DateTime.Now.ToString("MM/dd/yyyy");
            DBSupplier s = new DBSupplier();

            DR = s.getSupplier();
            while (DR.Read())
            {
                cmbsupname.Items.Add(DR[0]);
            }
        }
        private void Suppliers_Load(object sender, EventArgs e)
        {
            SqlDataAdapter da;
            DBSupplier     i = new DBSupplier();

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

            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
Example #4
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);
                    }
                }
            }
        }
Example #6
0
        private void Purchase_Order_Load(object sender, EventArgs e)
        {
            txtdate.Text = System.DateTime.Today.ToString("M/d/yyyy");


            DBSupplier ds = new DBSupplier();

            DR = ds.getSupplier();
            while (DR.Read())
            {
                cmbsupname.Items.Add(DR[0]);
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            txtname.Text   = dataGridView1.CurrentRow.Cells["Item_Name"].Value.ToString();
            txtdes.Text    = dataGridView1.CurrentRow.Cells["Item_Description"].Value.ToString();
            txtstatus.Text = dataGridView1.CurrentRow.Cells["Item_Status"].Value.ToString();
            txtprice.Text  = dataGridView1.CurrentRow.Cells["Item_Price"].Value.ToString();
            txtqty.Text    = dataGridView1.CurrentRow.Cells["Item_Qty"].Value.ToString();
            int sup = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Supplier_ID"].Value);

            no = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_No"].Value);
            DBSupplier ds   = new DBSupplier();
            String     name = ds.getName(sup);

            comboBox1.SelectedItem = name;
        }
 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();
        }
        private void Items_Load(object sender, EventArgs e)
        {
            try
            {
                SqlDataAdapter da;
                DBItem         i = new DBItem();
                da = i.getItem();
                DataTable dt = new DataTable();
                da.Fill(dt);
                dataGridView1.DataSource = dt;

                DBSupplier    s = new DBSupplier();
                SqlDataReader DR;
                DR = s.getSupplier();
                while (DR.Read())
                {
                    comboBox1.Items.Add(DR[0]);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }