Пример #1
0
        public void insertSales(DataGridView gv, string proIDgv, string proQuanGV, string totGV, string totDisGV, int doneBy, DateTime dt, float totAmount, float totalDiscount, float given, float Return, string payType)
        {
            try
            {
                using (TransactionScope sc = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(30)))
                {
                    SqlCommand cmd = new SqlCommand("st_insertSales", MainClass.con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@done", doneBy);
                    cmd.Parameters.AddWithValue("@date", dt);
                    cmd.Parameters.AddWithValue("@totamt", totAmount);
                    cmd.Parameters.AddWithValue("@totdis", totalDiscount);

                    if (payType == "Cash")
                    {
                        cmd.Parameters.AddWithValue("@given", given);
                        cmd.Parameters.AddWithValue("@return", Return);
                        cmd.Parameters.AddWithValue("@payType", 0);
                    }
                    else if (payType == "Debit Card")
                    {
                        cmd.Parameters.AddWithValue("@given", 0);
                        cmd.Parameters.AddWithValue("@return", 0);
                        cmd.Parameters.AddWithValue("@payType", 1);
                    }
                    else if (payType == "Credit Card")
                    {
                        cmd.Parameters.AddWithValue("@given", 0);
                        cmd.Parameters.AddWithValue("@return", 0);
                        cmd.Parameters.AddWithValue("@payType", 2);
                    }
                    MainClass.con.Open();
                    salCount = cmd.ExecuteNonQuery();
                    if (salCount > 0)
                    {
                        SqlCommand Scmd = new SqlCommand("st_getSalesID", MainClass.con);
                        Scmd.CommandType = CommandType.StoredProcedure;
                        SaleID           = Convert.ToInt64(Scmd.ExecuteScalar());

                        foreach (DataGridViewRow row in gv.Rows)
                        {
                            SqlCommand ISCmd = new SqlCommand("st_insertSalesDetails", MainClass.con);
                            ISCmd.CommandType = CommandType.StoredProcedure;
                            ISCmd.Parameters.AddWithValue("@salID", SaleID);
                            ISCmd.Parameters.AddWithValue("@proID", Convert.ToInt64(row.Cells[proIDgv].Value.ToString()));
                            ISCmd.Parameters.AddWithValue("@quan", Convert.ToInt32(row.Cells[proQuanGV].Value.ToString()));
                            ISCmd.Parameters.AddWithValue("@sellPrice", Convert.ToSingle(row.Cells[totGV].Value.ToString()));
                            ISCmd.Parameters.AddWithValue("@discount", Convert.ToSingle(row.Cells[totDisGV].Value.ToString()));
                            ISCmd.ExecuteNonQuery();
                            int productStock    = Convert.ToInt32(r.getProductQuantityNoConnection(Convert.ToInt64(row.Cells[proIDgv].Value.ToString())));
                            int CurrentQuantity = Convert.ToInt32(row.Cells[proQuanGV].Value.ToString());
                            int finalQuantity   = productStock - CurrentQuantity;
                            u.UpdateStockNoConnection(Convert.ToInt64(row.Cells[proIDgv].Value.ToString()), finalQuantity);
                        }
                    }
                    MainClass.con.Close();
                    MainClass.ShowMSG("Sales Successful", "Success", "Success");
                    sc.Complete();
                }
            }
            catch (Exception ex)
            {
                MainClass.con.Close();
                MainClass.ShowMSG(ex.Message, "Error", "Error");
            }
        }
Пример #2
0
        public override void SaveBtn_Click(object sender, EventArgs e)
        {
            if (ProductTxt.Text == "")
            {
                productErrorLbl.Visible = true;
            }
            else
            {
                productErrorLbl.Visible = false;
            }
            if (barcodeTxt.Text == "")
            {
                barcodeErrorLbl.Visible = true;
            }
            else
            {
                barcodeErrorLbl.Visible = false;
            }
            if (ExpiryPicker.Value < DateTime.Now)
            {
                ExpiryErrorLbl.Visible = true;
                ExpiryErrorLbl.Text    = "Invalid Date";
            }
            else
            {
                ExpiryErrorLbl.Visible = false;
            }
            if (ExpiryPicker.Value.Date == DateTime.Now.Date)
            {
                ExpiryErrorLbl.Visible = false;
            }

            if (categoryCB.SelectedIndex == -1 || categoryCB.SelectedIndex == 0)
            {
                CategoryErrorLbl.Visible = true;
            }
            else
            {
                CategoryErrorLbl.Visible = false;
            }


            if (productErrorLbl.Visible || barcodeErrorLbl.Visible || CategoryErrorLbl.Visible)
            {
                MainClass.ShowMSG("fields with * are mandatory", "stop", "Error");//Error is the type of message
            }
            else
            {
                if (edit == 0)//code for save operation
                {
                    Insertion i = new Insertion();
                    if (ExpiryPicker.Value.Date == DateTime.Now.Date)
                    {
                        i.insertProduct(ProductTxt.Text, barcodeTxt.Text, Convert.ToInt32(categoryCB.SelectedValue));
                    }
                    else
                    {
                        i.insertProduct(ProductTxt.Text, barcodeTxt.Text, Convert.ToInt32(categoryCB.SelectedValue), ExpiryPicker.Value);
                    }

                    r.showProduct(ProductdataGridView, ProductIDGV, NameGV, BarcodeGV, ExpiryGV, CategoryGV, CategoryIDGV);
                    MainClass.disable_reset(leftPanel);
                }
                else if (edit == 1)//code for update operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        Updation u = new Updation();
                        if (ExpiryPicker.Value.Date == DateTime.Now.Date)
                        {
                            u.updateProduct(proID, ProductTxt.Text, barcodeTxt.Text, Convert.ToInt32(categoryCB.SelectedValue));
                        }
                        else
                        {
                            u.updateProduct(proID, ProductTxt.Text, barcodeTxt.Text, Convert.ToInt32(categoryCB.SelectedValue), ExpiryPicker.Value);
                        }
                        r.showProduct(ProductdataGridView, ProductIDGV, NameGV, BarcodeGV, ExpiryGV, CategoryGV, CategoryIDGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
Пример #3
0
 public override void EditBtn_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.enable(leftPanel);
 }
Пример #4
0
 private void Products_Load(object sender, EventArgs e)
 {
     MainClass.disable_reset(leftPanel);
     r.getCategoryList("st_getCategoriesList", categoryCB, "Category", "ID");
 }
Пример #5
0
        private void CartBtn_Click(object sender, EventArgs e)
        {
            if (SupplierDD.SelectedIndex == 0)
            {
                SupplierErrorLbl.Visible = true;
            }
            else
            {
                SupplierErrorLbl.Visible = false;
            }
            if (BarcodeTxt.Text == "")
            {
                BarcodeErrorLbl.Visible = true;
            }
            else
            {
                BarcodeErrorLbl.Visible = false;
            }
            if (ProductTxt.Text == "")
            {
                ProductErrorLbl.Visible = true;
            }
            else
            {
                ProductErrorLbl.Visible = false;
            }
            if (PerUnitTxt.Text == "")
            {
                PerUnitErrorLbl.Visible = true;
            }
            else
            {
                PerUnitErrorLbl.Visible = false;
            }

            if (QuantityTxt.Text == "")
            {
                QuantityErrorLbl.Visible = true;
            }
            else
            {
                QuantityErrorLbl.Visible = false;
            }

            if (SupplierErrorLbl.Visible || BarcodeErrorLbl.Visible || ProductErrorLbl.Visible || PerUnitErrorLbl.Visible || QuantityErrorLbl.Visible)
            {
                MainClass.ShowMSG("fields with * are mandatory", "stop", "Error");//Error is the type of message
            }
            else
            {
                PurchasedataGridView.Rows.Add(productID, ProductTxt.Text, QuantityTxt.Text, PerUnitTxt.Text, TotLbl.Text);
                gt              += Convert.ToSingle(TotLbl.Text);
                GrossLbl.Text    = gt.ToString();
                productID        = 0;
                ProductTxt.Text  = "";
                PerUnitTxt.Text  = "";
                BarcodeTxt.Text  = "";
                TotLbl.Text      = "0.00";
                QuantityTxt.Text = "";
                Array.Clear(prodArr, 0, prodArr.Length);
            }
        }
Пример #6
0
        public override void ViewBtn_Click(object sender, EventArgs e)
        {
            PurchaseInvoiceDetails piDetail = new PurchaseInvoiceDetails();

            MainClass.showWindow(piDetail, this, ActiveForm);
        }