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

            if (metroTextBox4.Text.Length == 0 && metroTextBox3.Text.Length == 0 && metroTextBox5.Text.Length == 0)
            {
                error = 1;
                MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbPorderNo.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select a Purchase Order Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (metroComboBox1.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (metroTextBox4.Text.Any(Char.IsLetter))
            {
                error = 1;
                MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (error == 0)
            {
                int    flag             = 0;
                String date             = txtdate.Text;
                int    Purchase_OrderNo = Convert.ToInt32(cmbPorderNo.SelectedItem);
                DBGRN  g                = new DBGRN();
                int    GRN_No           = g.setGRN(count_qty, count_tot, date, u_id, Purchase_OrderNo);
                DBGRN_Item_reference gp = new DBGRN_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);
                        line = gp.setData(itemno, itemqty, itemtot, GRN_No);
                        di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag);
                    }
                }
                if (line == 1)
                {
                    MessageBox.Show("Data Entered Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(" Database Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 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 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 mtAdd_Click(object sender, EventArgs e)
        {
            int error = 0;

            if (cmbcusnic.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select a NIC number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (cmbitemname.SelectedIndex == 0)
            {
                error = 1;
                MessageBox.Show("Please select an Item Name");
            }
            if (txttotqty.Text.Length == 0 && txtprice.Text.Length == 0)
            {
                error = 1;
                MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (txtprice.Text.Any(Char.IsLetter))
            {
                error = 1;
                MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (error == 0)

            {
                int            flag     = 0;
                int            salesno  = Convert.ToInt32(cmbsorder.SelectedItem);
                String         date     = txtdate.Text;
                int            Users_ID = u_id;
                DBSalesReturns dp       = new DBSalesReturns();
                int            sr_no    = dp.setSalesReturn(count_tot, count_qty, Users_ID, cusno, salesno);
                DBSalesReturns_Item_reference SR_I_ref = new DBSalesReturns_Item_reference();
                foreach (DataGridViewRow Datarow in dataGridView1.Rows)
                {
                    if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null)
                    {
                        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();
                        SR_I_ref.setReference(sr_no, itemno, itemqty, itemtot);
                        di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag);
                    }
                }
            }
        }