Exemple #1
0
        private void ImportFileData(DataTable dt)
        {
            try
            {
                Updation update = new Updation();

                foreach (DataRow row in dt.Rows)
                {
                    DataTable dtProductId = retrieve.GetId("usp_GetProductID", row[0].ToString());
                    //stocks in
                    update.UpdateIncreaseAvailableStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[2]), Convert.ToDateTime(row[1]));
                    //stocks out
                    update.UpdateDecreaseAvailableStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[3]), Convert.ToDateTime(row[1]));
                    //stock onhold
                    update.UpdateIncreaseInOnHoldStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[4]), Convert.ToDateTime(row[1]));
                    //resolve onhold
                    update.UpdateResolveInOnHoldStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[5]), Convert.ToDateTime(row[1]));
                    //stock rejected
                    update.UpdateIncreaseRejectedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[6]), Convert.ToDateTime(row[1]));
                    //resolve rejected
                    update.UpdateIResolveRejectedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[7]), Convert.ToDateTime(row[1]));
                    //stock reworked
                    update.UpdateIncreaseInReworkedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[8]), Convert.ToDateTime(row[1]));
                    //resolve reworked
                    update.UpdateResolveInReworkedStocks(Convert.ToInt32(dtProductId.Rows[0][0].ToString()), Convert.ToDecimal(row[9]), Convert.ToDateTime(row[1]));
                }

                MainClass.ShowMessage("Stocks Updated Successfully. ", "Success", "Success");
            }
            catch (Exception exp)
            {
                MainClass.ShowMessage(exp.Message, "Error", "Error");
            }
        }
Exemple #2
0
        public override void buttonSave_Click(object sender, EventArgs e)
        {
            if (dataGridViewSalesLines.Rows.Count > 0)
            {
                int       SalesID = 0;
                Insertion insert  = new Insertion();
                using (TransactionScope tc = new TransactionScope())
                {
                    SalesID = insert.SaveSales(Convert.ToInt32(comboBoxCustomer.SelectedValue), Convert.ToDecimal(labelGrandTotalValue.Text), Retrievel.User_ID);
                    int SalesLines = 0;
                    foreach (DataGridViewRow row in dataGridViewSalesLines.Rows)
                    {
                        SalesLines += insert.SaveSalesLine(SalesID, Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ProductTotalPrice"].Value), Convert.ToDecimal(row.Cells["ProductQuantityGv"].Value), row.Cells["Unit"].Value.ToString(), Convert.ToInt32(row.Cells[1].Value));
                        if (SalesLines > 0) //decrease the stock
                        {
                            Updation update = new Updation();

                            int rowsDec = update.UpdateDecreaseAvailableStocks(Convert.ToInt32(row.Cells["ProductIdGv"].Value), Convert.ToDecimal(row.Cells["ProductQuantityGv"].Value));
                        }
                    }
                    if (SalesLines > 0)
                    {
                        MainClass.ShowMessage("Sales Invoice Created Successfully.", "Success", "Success");
                        dataGridViewSalesLines.Rows.Clear();
                        textBoxSalesNumber.Text    = retrieve.RetrunSalesNumber().ToString();
                        comboBoxCustomer.Text      = "";
                        comboBoxSelectProduct.Text = "";
                        textBoxUnit.Clear();
                        textBoxQuantity.Clear();
                        textBoxProdCost.Clear();
                        textBoxTotalCost.Clear();
                        CreateSalesPdfReport(SalesID);
                        labelGrandTotalValue.Text = "0.00";
                    }
                    else
                    {
                        MainClass.ShowMessage("Unable to create Sales Invoice.", "Error", "Error");
                    }
                    tc.Complete();
                }
            }
        }
        private void buttonStocksOut_Click(object sender, EventArgs e)
        {
            if (comboBoxSelectProduct.SelectedIndex == -1)
            {
                labelProductDateError.Visible = true;
            }
            else
            {
                labelProductDateError.Visible = false;
            }
            if (textBoxQuantity.Text == "")
            {
                labelQuantityError.Visible = true;
            }
            else
            {
                labelQuantityError.Visible = false;
            }
            if (string.IsNullOrEmpty(dateTimePickerEntryDate.Text))
            {
                labelEntryDateError.Visible = true;
            }
            else
            {
                labelEntryDateError.Visible = false;
            }
            if (labelProductDateError.Visible || labelQuantityError.Visible || labelEntryDateError.Visible)
            {
                MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message.
            }
            else
            {
                Updation update = new Updation();

                int row = update.UpdateDecreaseAvailableStocks(Convert.ToInt32(comboBoxSelectProduct.SelectedValue.ToString()), Convert.ToDecimal(textBoxQuantity.Text), dateTimePickerEntryDate.Value);
                retrieve.ShowStock(dataGridViewProduct, ProductIdGv, ProductNameGv, ProductCodeGv, ProductUnitGv, ProductMinValGv, AvailableStocks, ReworkedStock, RejectedStock, OnholdStock);
                foreach (DataGridViewRow rows in dataGridViewProduct.Rows)
                {
                    if (Convert.ToDecimal(rows.Cells["ProductMinValGv"].Value) < Convert.ToDecimal(rows.Cells["AvailableStocks"].Value))
                    {
                        rows.Cells["ProductNameGv"].Style.BackColor = Color.LightGreen;
                        rows.Cells["ProductNameGv"].Style.ForeColor = Color.Black;

                        rows.Cells["AvailableStocks"].Style.BackColor = Color.LightGreen;
                        rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black;
                    }
                    else
                    {
                        rows.Cells["AvailableStocks"].Style.BackColor = Color.IndianRed;
                        rows.Cells["AvailableStocks"].Style.ForeColor = Color.Black;


                        rows.Cells["ProductNameGv"].Style.BackColor = Color.IndianRed;
                        rows.Cells["ProductNameGv"].Style.ForeColor = Color.Black;
                    }
                }

                if (row > 0)
                {
                    MainClass.ShowMessage("Stocks decreased sucessfully", "Success", "Success");
                    textBoxQuantity.Clear();
                }
                else
                {
                    MainClass.ShowMessage("Please add stock of the product first through stock in or receiving.", "Error", "Error");
                }
            }
        }