Пример #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");
            }
        }
        private void buttonAddToStocks_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 (labelProductDateError.Visible || labelQuantityError.Visible)
            {
                MainClass.ShowMessage("Fields with * are mandatory", "Error", "Error"); //Error is the type of message.
            }
            else
            {
                Updation update = new Updation();

                update.UpdateIncreaseInOnHoldStocks(Convert.ToInt32(comboBoxSelectProduct.SelectedValue.ToString()), Convert.ToDecimal(textBoxQuantity.Text), dateTimePickerEntryDate.Value);
                ShowAllDataInGrid();
                //foreach (DataGridViewRow rows in dataGridViewProduct.Rows)
                //{
                //    if(Convert.ToDecimal(rows.Cells["ProductMinValGv"].Value)< Convert.ToDecimal(rows.Cells["AvailableStocks"].Value))
                //    {
                //        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;
                //    }
                //}

                MainClass.ShowMessage("Stocks added sucessfully", "Success", "Success");
                textBoxQuantity.Clear();
            }
        }