Beispiel #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int q;

            if (e.RowIndex != -1 && e.ColumnIndex != -1)
            {
                if (e.ColumnIndex == 6)
                {
                    DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
                    DialogResult    dr  = MessageBox.Show("Are u sure,want to delete? " + row.Cells["proGV"].Value.ToString() + "from purchase invoice ?\nWARNING\t\nDELETION OF PRODUCT WILL EFFECT STOCK", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr == DialogResult.Yes)
                    {
                        using (TransactionScope sc = new TransactionScope())
                        {
                            i.insertDeletedItem(Convert.ToInt64(purDD.SelectedValue.ToString()), Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), retrival.USER_ID, DateTime.Today);

                            object ob = r.getProductQuantity(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()));
                            if (ob != null)
                            {
                                q  = Convert.ToInt32(ob);
                                q -= Convert.ToInt32(row.Cells["quantGV"].Value.ToString());
                                u.updateStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), q);
                                float tot = Convert.ToSingle(grossLabel.Text) - Convert.ToSingle(row.Cells["totalGV"].Value.ToString());
                                grossLabel.Text = tot.ToString();
                                d.delete(Convert.ToInt64(row.Cells["mPIDGV"].Value.ToString()), "st_deleteProductFromPID", "@mPID");
                                dataGridView1.Rows.Remove(row);
                            }

                            sc.Complete();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public override void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                Int64     purchaseInvoiceID;
                insertion i = new insertion();
                updation  u = new updation();

                using (TransactionScope sc = new TransactionScope())
                {
                    purchaseInvoiceID = i.insertPurchaseInvoice(DateTime.Today, retrival.USER_ID, Convert.ToInt32(supplierDD.SelectedValue));

                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        co += i.insertPurchaseInvoiceDetails(purchaseInvoiceID, Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()), Convert.ToSingle(row.Cells["totalGV"].Value.ToString()));
                        if (r.checkproductPriceExistence(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString())))
                        {
                            u.updateProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString()));
                        }
                        else
                        {
                            i.insertProductPrice(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToSingle(row.Cells["pupGV"].Value.ToString()));
                        }

                        int    q;
                        object ob = r.getProductQuantity(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()));
                        if (ob != null)
                        {
                            q  = Convert.ToInt32(ob);
                            q += Convert.ToInt32(row.Cells["quantGV"].Value.ToString());
                            u.updateStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), q);
                        }

                        else
                        {
                            i.insertStock(Convert.ToInt32(row.Cells["proIDGV"].Value.ToString()), Convert.ToInt32(row.Cells["quantGV"].Value.ToString()));
                        }
                    }
                    if (co > 0)
                    {
                        MainClass.showMG("Purchase Invoice Created Successfullly..", "success", "success");
                    }
                    else
                    {
                        MainClass.showMG("error", "error", "error");
                    }
                    sc.Complete();
                }
            }
        }
Beispiel #3
0
        private void barcodeTxt_Validating(object sender, CancelEventArgs e)
        {
            if (barcodeTxt.Text != "")
            {
                GrossTxt.Text         = "";
                TotalDiscountTxt.Text = "";
                amountTxt.Text        = "";
                changeGiveTxt.Text    = "";
                int qCount = 0;
                int sQuant = 0;
                int nCount = 0;

                prodARR = r.getProductsWRTBarcode(barcodeTxt.Text);
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (prodARR[0] == row.Cells["proIDGV"].Value.ToString())
                    {
                        qCount = qCount + Convert.ToInt32(row.Cells["quantGV"].Value.ToString());
                    }
                }
                sQuant = Convert.ToInt32(r.getProductQuantity(Convert.ToInt64(prodARR[0])));

                nCount = sQuant - qCount;

                if (nCount <= 0)
                {
                }
                else
                {
                    if (dataGridView1.RowCount == 0)
                    {
                        dataGridView1.Rows.Add(Convert.ToInt32(prodARR[0]), prodARR[1], 1, Convert.ToSingle(prodARR[3]), prodARR[4], Convert.ToSingle(prodARR[5]));
                    }
                    else
                    {
                        foreach (DataGridViewRow row in dataGridView1.Rows)
                        {
                            if (row.Cells["proIDGV"].Value.ToString() == prodARR[0])
                            {
                                productCheck = true;
                                break;
                            }
                            else
                            {
                                productCheck = false;
                            }
                        }
                        if (productCheck == true)
                        {
                            foreach (DataGridViewRow row in dataGridView1.Rows)
                            {
                                if (row.Cells["proIDGV"].Value.ToString() == prodARR[0])
                                {
                                    float disc = 0;
                                    row.Cells["quantGV"].Value = Convert.ToInt32(row.Cells["quantGV"].Value.ToString()) + 1;
                                    if (row.Cells["disGV"].Value.ToString() != null)
                                    {
                                        disc = Convert.ToSingle(row.Cells["disGV"].Value.ToString()) + Convert.ToSingle(row.Cells["disGV"].Value.ToString());
                                        row.Cells["disGV"].Value = disc;
                                    }
                                    float tot = (Convert.ToSingle(row.Cells["pupGV"].Value.ToString()) * Convert.ToInt32(row.Cells["quantGV"].Value.ToString())) - Convert.ToSingle(row.Cells["disGV"].Value.ToString());
                                    row.Cells["totalGV"].Value = tot;
                                }
                            }
                        }

                        else
                        {
                            dataGridView1.Rows.Add(Convert.ToInt32(prodARR[0]), prodARR[1], 1, Convert.ToSingle(prodARR[3]), prodARR[4], Convert.ToSingle(prodARR[5]));
                        }
                    }
                    foreach (DataGridViewRow item in dataGridView1.Rows)
                    {
                        GROSS += Convert.ToSingle(item.Cells["totalGV"].Value.ToString());
                    }
                    grossLabel.Text = GROSS.ToString();
                    GROSS           = 0;
                    barcodeTxt.Focus();
                    barcodeTxt.Clear();
                }
            }
        }