Exemplo n.º 1
0
 /// <summary>
 /// Function to fill the product details in dataGridView from productCreationPopup
 /// </summary>
 /// <param name="productcreation"></param>
 /// <param name="decproductId"></param>
 /// <param name="decCurrentRowIndex"></param>
 public void productDetailsFillFromProductCreation(frmProductCreation productcreation, decimal decproductId, decimal decCurrentRowIndex)
 {
     try
     {
         decimal decCurrentConversionRate = 0;
         DataTable dtbl = new DataTable();
         UnitConvertionSP SPUnitConversion = new UnitConvertionSP();
         BatchSP spBatch = new BatchSP();
         ProductInfo infoProductFill = new ProductInfo();
         ProductSP spproduct = new ProductSP();
         ProductInfo infoProduct = new ProductInfo();
         int inI = dgvPurchaseReturn.CurrentRow.Index;
         if (inI == dgvPurchaseReturn.Rows.Count - 1)
         {
             dgvPurchaseReturn.Rows.Add();
         }
         if (decproductId != 0)
         {
             infoProduct = spproduct.ProductView(decproductId);
             SerialNo();
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductCode"].Value = infoProduct.ProductCode;
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductId"].Value = decproductId.ToString();
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtproductName"].Value = infoProduct.ProductName;
             dgvPurchaseReturn.Rows[inI].Cells["dgvcmbGodown"].Value = infoProduct.GodownId;
             dgvPurchaseReturn.Rows[inI].Cells["dgvcmbRack"].Value = infoProduct.RackId;
             UnitComboFill(infoProduct.ProductId, dgvPurchaseReturn.CurrentRow.Index, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex);
             dgvPurchaseReturn.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtrate"].Value = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces);
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionSP().UnitconversionIdViewByUnitIdAndProductId(infoProduct.UnitId, infoProduct.ProductId));
             dgvPurchaseReturn.CurrentRow.Cells["dgvtxtConversionRate"].Value = SPUnitConversion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvPurchaseReturn.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()));
             BatchComboFill(decproductId, inI, dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].ColumnIndex);
             dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].Value = spBatch.BatchIdViewByProductId(decproductId);
             RackComboFill(infoProduct.GodownId, inI, dgvPurchaseReturn.Rows[inI].Cells["dgvcmbRack"].ColumnIndex);
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtqty"].Value = "0";
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtbarcode"].Value = spBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvPurchaseReturn.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()));
             dtbl = SPUnitConversion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName);
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[0]["conversionRate"].ToString();
             decCurrentConversionRate = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvtxtConversionRate"].Value.ToString());
             AmountCalculation("dgvtxtqty", inI);
             dgvPurchaseReturn.Rows[inI].Cells["dgvtxtqty"].Selected = true;
             dgvPurchaseReturn.Rows[inI + 1].Selected = false;
         }
         dgvPurchaseReturn.Rows[inI].HeaderCell.Value = "X";
         dgvPurchaseReturn.Rows[inI].HeaderCell.Style.ForeColor = Color.Red;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:24" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Function to fill batch combobox for production
 /// </summary>
 public void BatchComboFillProduction(decimal decProductId, int inRow, int inColumn)
 {
     try
     {
         DataTable dtbl = new DataTable();
         BatchSP spBatch = new BatchSP();
         dtbl = spBatch.BatchNamesCorrespondingToProduct(decProductId);
         DataGridViewComboBoxCell dgvcmbBatchCell = (DataGridViewComboBoxCell)dgvProduction.Rows[inRow].Cells[inColumn];
         dgvcmbBatchCell.DataSource = dtbl;
         dgvcmbBatchCell.ValueMember = "batchId";
         dgvcmbBatchCell.DisplayMember = "batchNo";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:10" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Get the Product details from the Product Search form
        /// </summary>
        /// <param name="frmProductSearchPopup"></param>
        /// <param name="decproductId"></param>
        /// <param name="decCurrentRowIndex"></param>
        public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex)
        {
            ProductInfo infoProduct = new ProductInfo();
            ProductSP spProduct = new ProductSP();
            BatchSP spBatch = new BatchSP();
            DataTable dtbl = new DataTable();
            UnitConvertionSP spUnitConversion = new UnitConvertionSP();
            try
            {
                base.Show();
                this.frmProductSearchPopupObj = frmProductSearchPopup;
                infoProduct = spProduct.ProductView(decproductId);
                if (IsdgvConsuption)
                {
                    int inRowcount = dgvConsumption.Rows.Count;
                    dgvConsumption.Rows.Add();
                    for (int i = 0; i < inRowcount; i++)
                    {
                        if (i == decCurrentRowIndex)
                        {
                            dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].Value = infoProduct.ProductCode;
                            strProductCode = infoProduct.ProductCode;
                            ProductDetailsFillConsumption(strProductCode, i, "ProductCode");
                        }
                    }
                }
                else
                {
                    int inRowcount = dgvProduction.Rows.Count;
                    dgvProduction.Rows.Add();
                    for (int i = 0; i < inRowcount; i++)
                    {
                        if (i == decCurrentRowIndex)
                        {
                            dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].Value = infoProduct.ProductCode;
                            strProductCode = infoProduct.ProductCode;
                            ProductDetailsFillProduction(strProductCode, i, "ProductCode");
                        }
                    }
                }

                frmProductSearchPopupObj.Close();
                frmProductSearchPopupObj = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:92" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 ///Function for ReturnFromProductCreationPopup
 /// </summary>
 public void ReturnFromProductCreation(decimal decProductId)
 {
     ProductInfo infoProduct = new ProductInfo();
     ProductSP spProduct = new ProductSP();
     BatchSP spBatch = new BatchSP();
     DataTable dtbl = new DataTable();
     UnitConvertionSP spUnitConversion = new UnitConvertionSP();
     try
     {
         this.Enabled = true;
         this.BringToFront();
         int inI = dgvProduct.CurrentRow.Index;
         if (inI == dgvProduct.Rows.Count - 1)
         {
             dgvProduct.Rows.Add();
         }
         if (decProductId != 0)
         {
             infoProduct = spProduct.ProductView(decProductId);
             dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode.ToString();
             dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value = decProductId.ToString();
             dgvProduct.Rows[inI].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
             dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value = infoProduct.SalesRate.ToString();
             UnitComboFill1(decProductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbUnit"].ColumnIndex);
             dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;
             BatchComboFill(decProductId, inI, dgvProduct.Rows[inI].Cells["dgvcmbBatch"].ColumnIndex);
             dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value = spBatch.BatchIdViewByProductId(decProductId);
             dgvProduct.Rows[inI].Cells["dgvtxtBarcode"].Value = spBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()));
             GridGodownComboFill(decProductId, dgvProduct.CurrentRow.Index, dgvProduct.Rows[inI].Cells["dgvcmbGodown"].ColumnIndex);
             dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value = infoProduct.GodownId;
             RackComboFill1(infoProduct.GodownId, inI, dgvProduct.Rows[inI].Cells["dgvcmbRack"].ColumnIndex);
             dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value = infoProduct.RackId;
             dtbl = spUnitConversion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName);
             dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[0]["unitconversionId"].ToString();
             dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[0]["conversionRate"].ToString();
             decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value.ToString());
             decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
             AmountCalculation("dgvtxtQty", dgvProduct.CurrentRow.Index);
             dgvProduct.Rows[inI].HeaderCell.Value = "X";
             dgvProduct.Rows[inI].HeaderCell.Style.ForeColor = Color.Red;
             TotalAmountCalculation();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Batch combobox fill
 /// </summary>
 public void BatchComboFill()
 {
     try
     {
         BatchSP spBatch = new BatchSP();
         DataTable dtbl = spBatch.BatchViewAll();
         cmbBatchNo.DataSource = dtbl;
         cmbBatchNo.DisplayMember = "batchNo";
         cmbBatchNo.ValueMember = "batchId";
         DataRow dr = dtbl.NewRow();
         dr["batchId"] = -1;
         dr["batchNo"] = "All";
         dtbl.Rows.InsertAt(dr, 0);
         cmbBatchNo.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show(" PVSBR:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 6
0
 public void ProductDetailsFill(int inRowIndex, string strFillMode)
 {
     try
     {
         ProductInfo infoProduct = new ProductInfo();
         BatchSP spBatch = new BatchSP();
         StockPostingSP spStockPosting = new StockPostingSP();
         string strPrdCode = string.Empty;
         string strProductName = string.Empty;
         if (strFillMode == "ProductCode")
         {
             if (dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value as string != string.Empty)
             {
                 strPrdCode = dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value.ToString();
             }
             infoProduct = new ProductSP().ProductViewByCode(strPrdCode);
         }
         if (strFillMode == "ProductName")
         {
             if (dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value != null && dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty)
             {
                 strProductName = dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value.ToString();
             }
             infoProduct = new ProductSP().ProductViewByName(strProductName);
         }
         if (infoProduct.ProductId != 0)
         {
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
             string strproductId = Convert.ToString(infoProduct.ProductId);
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = infoProduct.ProductId;
             UnitComboFill1(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].ColumnIndex);
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;
             BatchComboFill(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].ColumnIndex);
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = spStockPosting.BatchViewByProductId(Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value));
             string strBarcode = spBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value.ToString()));
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = strBarcode;
             GridGodownComboFill(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].ColumnIndex);
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = infoProduct.GodownId;
             RackComboFill1(Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value), inRowIndex, dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].ColumnIndex);
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].Value = infoProduct.RackId;
             UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
             DataTable dtblUnitByProduct = new DataTable();
             dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(strproductId);
             foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
             {
                 if (dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                 {
                     dgvProduct.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                     dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                 }
             }
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces);
             decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
             decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value.ToString());
             decimal decProductId = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value.ToString());
             decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value.ToString());
             getProductRate(inRowIndex, decProductId, decBatchId);
         }
         else
         {
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbRack"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtRate"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
             dgvProduct.Rows[inRowIndex].Cells["dgvtxtQty"].Value = string.Empty;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN47:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Fill Product Details Curresponding Product code or Barcode
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     BatchSP spBatch = new BatchSP();
     try
     {
         ProductInfo infoProduct = new ProductInfo();
         DataTable dtbl = new DataTable();
         isValueChange = false;
         isDoAfterGridFill = false;
         decimal DefaultRate = 0;
         if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtBarcode")
         {
             string strBCode = string.Empty;
             if (!dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].ReadOnly && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString() != string.Empty)
             {
                 strBCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString();
             }
             dtbl = new ProductSP().ProductDetailsCoreespondingToBarcode(strBCode);
             if (dtbl.Rows.Count > 0)
             {
                 foreach (DataRow RowDetails in dtbl.Rows)
                 {
                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value = RowDetails["productId"].ToString();
                     decimal decProductId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString());
                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = RowDetails["productCode"].ToString();
                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = RowDetails["productName"].ToString();
                     UnitComboFill1(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].ColumnIndex);
                     dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(RowDetails["unitId"].ToString());
                     BatchComboFill(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, Convert.ToInt32(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].ColumnIndex));
                     dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(RowDetails["batchId"].ToString());
                     GridGodownComboFill(Convert.ToDecimal(RowDetails["productId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].ColumnIndex);
                     dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(RowDetails["godownId"].ToString());
                     RackComboFill1(Convert.ToDecimal(RowDetails["godownId"].ToString()), e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].ColumnIndex);
                     dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].Value = Convert.ToDecimal(RowDetails["rackId"].ToString());
                     decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString());
                     UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                     DataTable dtblUnitByProduct = new DataTable();
                     dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString());
                     foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                     {
                         if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                         {
                             dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                             dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                         }
                     }
                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(Convert.ToDecimal(RowDetails["salesRate"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                     decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                     decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString());
                     getProductRate(e.RowIndex, decProductId, decBatchId);
                 }
             }
             else
             {
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvcmbRack"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty;
             }
         }
         else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductCode")
         {
             isValueChange = false;
             isDoAfterGridFill = false;
             ProductDetailsFill(dgvProduct.CurrentRow.Index, "ProductCode");
         }
         else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductName")
         {
             isValueChange = false;
             isDoAfterGridFill = false;
             ProductDetailsFill(dgvProduct.CurrentRow.Index, "ProductName");
         }
         else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate")
         {
             if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null)
             {
                 if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty)
                 {
                     DefaultRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value);
                 }
             }
         }
         AmountCalculation("dgvtxtQty", e.RowIndex);
         TotalAmountCalculation();
         isValueChange = true;
         isDoAfterGridFill = true;
         CheckInvalidEntries(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN68:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Function for call from productRegister
        /// </summary>
        public void CallFromProductRegister(decimal decId, frmProductRegister frmProRegister)
        {
            try
            {
                base.Show();

                this.frmProductRegisterObj = frmProRegister;
                frmProductRegisterObj.Enabled = false;

                ProductSP spProduct = new ProductSP();
                ProductInfo infoProduct = new ProductInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                BatchInfo infoBatch = new BatchInfo();
                StockPostingSP spStockposting = new StockPostingSP();
                BatchSP spBatch = new BatchSP();
                DataTable dtbl = new DataTable();
                UnitSP spUnit = new UnitSP();
                decProductIdForEdit = decId;
                infoProduct = spProduct.ProductView(decId);
                strUnitNameForGrid = spUnit.UnitName(infoProduct.UnitId);
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                //cmbUnit.Enabled = false;
                txtName.Text = infoProduct.ProductName;
                txtProductCode.Text = infoProduct.ProductCode;
                cmbGroup.SelectedValue = infoProduct.GroupId;
                cmbBrand.SelectedValue = infoProduct.BrandId;
                cmbUnit.SelectedValue = infoProduct.UnitId;
                if (spProduct.ProductReferenceCheck(decId))
                {
                    cmbUnit.Enabled = false;
                }

                decUnitIdForUpdate = infoProduct.UnitId;
                cmbSize.SelectedValue = infoProduct.SizeId;
                cmbModalNo.SelectedValue = infoProduct.ModelNoId;
                cmbTax.SelectedValue = infoProduct.TaxId;
                cmbTaxApplicableOn.SelectedItem = infoProduct.TaxapplicableOn;
                txtPurchaseRate.Text = infoProduct.PurchaseRate.ToString();
                txtSalesRate.Text = infoProduct.SalesRate.ToString();
                txtMrp.Text = infoProduct.Mrp.ToString();
                txtMinimumStock.Text = infoProduct.MinimumStock.ToString();
                txtMaximumStock.Text = infoProduct.MaximumStock.ToString();
                txtReorderLevel.Text = infoProduct.ReorderLevel.ToString();
                txtPartNo.Text = infoProduct.PartNo;
                cmbDefaultGodown.SelectedValue = infoProduct.GodownId;
                cmbDefaultRack.SelectedValue = infoProduct.RackId;

                if (infoProduct.IsBom)
                {
                    cmbBom.SelectedIndex = 1;
                    isBomFromRegister = true;
                }
                if (infoProduct.Ismultipleunit)
                {
                    cmbMultipleUnit.SelectedIndex = 1;
                    isMulUnitFromRgister = true;
                }


                if (infoProduct.Isopeningstock)
                {
                    isOpeningStockForUpdate = true;
                    OpeningStockGridFill();

                }

                if (infoProduct.IsallowBatch)
                {
                    OpeningStockGridWithBathFill();
                }
                else
                {
                    cmbAllowBatch.SelectedIndex = 0;
                    txtPartNo.Text = spBatch.PartNoReturn(decProductIdForEdit);
                }
                if (infoProduct.Ismultipleunit)
                {
                    cmbMultipleUnit.SelectedIndex = 1;
                }
                else
                {
                    cmbMultipleUnit.SelectedIndex = 0;
                }

                if (infoProduct.IsBom)
                {
                    cmbBom.SelectedIndex = 1;

                }
                else
                {
                    cmbBom.SelectedIndex = 0;
                }

                if (infoProduct.Isopeningstock)
                {
                    cmbOpeningStock.SelectedIndex = 1;
                }
                else
                {
                    cmbOpeningStock.SelectedIndex = 0;
                }


                if (infoProduct.IsActive)
                {
                    cbxActive.Checked = true;
                }
                else
                {
                    cbxActive.Checked = false;
                }
                if (infoProduct.IsshowRemember)
                {
                    cbxReminder.Checked = true;
                }
                else
                {
                    cbxReminder.Checked = false;
                }
                txtNarration.Text = infoProduct.Narration;


            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:63" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// IF AllowBatch Selected No While Updating
        /// </summary>
        public void DeleteBatchFromOpeningStock()
        {
            BatchSP spBatch = new BatchSP();

            spBatch.DeleteBatchForProductUpdate(decProductIdForEdit);
            isBatchRemoved = true;
            BatchWithBarCode();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Function to edit Product table
        /// </summary>
        public void ProductEditFill()
        {

            try
            {
                ProductSP spProduct = new ProductSP();
                ProductInfo infoProduct = new ProductInfo();
                UnitConvertionSP spUnitConvertion = new UnitConvertionSP();
                UnitConvertionInfo infoUnitConvertion = new UnitConvertionInfo();
                BatchSP spBatch = new BatchSP();
                infoProduct.ProductName = txtName.Text.Trim();
                infoProduct.ProductCode = txtProductCode.Text.Trim();
                if (txtPurchaseRate.Text.Trim() == string.Empty)
                {
                    infoProduct.PurchaseRate = 0;
                }
                else
                {
                    infoProduct.PurchaseRate = Convert.ToDecimal(txtPurchaseRate.Text.Trim());
                }
                if (txtSalesRate.Text.Trim() == string.Empty)
                {
                    infoProduct.SalesRate = 0;
                }
                else
                {
                    infoProduct.SalesRate = Convert.ToDecimal(txtSalesRate.Text.Trim());
                }
                if (txtMrp.Text.Trim() == string.Empty)
                {
                    infoProduct.Mrp = 0;
                }
                else
                {
                    infoProduct.Mrp = Convert.ToDecimal(txtMrp.Text);
                }

                infoProduct.MaximumStock = Convert.ToDecimal(txtMaximumStock.Text.Trim());
                infoProduct.MinimumStock = Convert.ToDecimal(txtMinimumStock.Text.Trim());
                infoProduct.ReorderLevel = Convert.ToDecimal(txtReorderLevel.Text.Trim());
                infoProduct.Extra1 = string.Empty;
                infoProduct.Extra2 = string.Empty;
                infoProduct.ExtraDate = DateTime.Now;
                infoProduct.TaxId = Convert.ToDecimal(cmbTax.SelectedValue);
                infoProduct.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue);
                infoProduct.GroupId = Convert.ToDecimal(cmbGroup.SelectedValue);
                infoProduct.Narration = txtNarration.Text;

                infoProduct.ProductId = decProductIdForEdit;
                infoUnitConvertion.ProductId = decProductIdForEdit;
                infoUnitConvertion.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue);
                if (cmbTax.SelectedIndex == 0)
                {
                    infoProduct.TaxapplicableOn = string.Empty;
                }
                else
                {
                    infoProduct.TaxapplicableOn = Convert.ToString(cmbTaxApplicableOn.SelectedItem);
                }
                if (cmbBrand.SelectedIndex != -1)
                {
                    infoProduct.BrandId = Convert.ToDecimal(cmbBrand.SelectedValue);
                }
                else
                {
                    infoProduct.BrandId = 1;
                }
                if (cmbSize.SelectedIndex != -1)
                {
                    infoProduct.SizeId = Convert.ToDecimal(cmbSize.SelectedValue);
                }
                else
                {
                    infoProduct.SizeId = 1;
                }
                if (cmbModalNo.SelectedIndex != -1)
                {
                    infoProduct.ModelNoId = Convert.ToDecimal(cmbModalNo.SelectedValue);
                }
                else
                {
                    infoProduct.ModelNoId = 1;
                }
                if (cmbDefaultGodown.SelectedIndex != -1)
                {
                    infoProduct.GodownId = Convert.ToDecimal(cmbDefaultGodown.SelectedValue);
                }
                else
                {
                    infoProduct.GodownId = 1;
                }
                if (cmbDefaultRack.SelectedIndex != -1)
                {
                    infoProduct.RackId = Convert.ToDecimal(cmbDefaultRack.SelectedValue);
                }
                else
                {
                    infoProduct.RackId = 1;
                }
                if (cmbAllowBatch.SelectedIndex == 0)
                {
                    infoProduct.IsallowBatch = false;
                    spBatch.PartNoUpdate(decProductIdForEdit, txtPartNo.Text.Trim());

                }
                else
                {
                    infoProduct.IsallowBatch = true;
                }
                if (cmbBom.SelectedIndex == 0)
                {
                    infoProduct.IsBom = false;
                }
                else
                {
                    if (isSaveBomCheck || isBomFromRegister)
                    {
                        infoProduct.IsBom = true;
                    }
                    else
                    {
                        infoProduct.IsBom = false;
                    }

                }

                if (cmbMultipleUnit.SelectedIndex == 0)
                {

                    infoProduct.Ismultipleunit = false;
                }
                else
                {
                    if ((isMulUnitFromRgister || isSaveMulUnitCheck))
                    {
                        infoProduct.Ismultipleunit = true;

                    }
                    else
                    {
                        infoProduct.Ismultipleunit = false;
                    }

                }
                if (cbxActive.Checked)
                {
                    infoProduct.IsActive = true;
                }
                else
                {
                    infoProduct.IsActive = false;
                }
                if (cbxReminder.Checked)
                {
                    infoProduct.IsshowRemember = true;
                }
                else
                {
                    infoProduct.IsshowRemember = false;
                }
                if (cmbOpeningStock.SelectedIndex == 0)
                {
                    infoProduct.Isopeningstock = false;
                }
                else
                {
                    infoProduct.Isopeningstock = true;
                }

                if (PublicVariables.isMessageEdit)
                {
                    if (Messages.UpdateMessage())
                    {
                        isUpdated = spProduct.ProductEdit(infoProduct);
                        spUnitConvertion.UnitConverstionEditWhenProductUpdating(infoUnitConvertion);
                    }
                }
                else
                {
                    isUpdated = spProduct.ProductEdit(infoProduct);
                    spUnitConvertion.UnitConverstionEditWhenProductUpdating(infoUnitConvertion);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:25" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemplo n.º 11
0
        /// <summary>
        /// Function to fill the DtaGridview With Batch While Updating
        /// </summary>
        public void OpeningStockGridWithBathFill()
        {

            try
            {
                DataTable dtbl = new DataTable();
                ProductSP spProduct = new ProductSP();
                BatchSP spBatch = new BatchSP();
                cmbAllowBatch.SelectedIndex = 1;
                isBatchForUpdate = true;

                dtbl = spProduct.ProductViewGridFillFromBatch(decProductIdForEdit);

                for (int i = 0; i < dtbl.Rows.Count; i++)
                {
                    dgvProductCreation.Rows[i].Cells["dgvtxtbatchId"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"]);
                    dgvProductCreation.Rows[i].Cells["dgvtxtExpDate"].Value = dtbl.Rows[i]["expiryDate"];
                    dgvProductCreation.Rows[i].Cells["dgvtxManfDate"].Value = dtbl.Rows[i]["manufacturingDate"];
                    dgvProductCreation.Rows[i].Cells["dgvtxtbatch"].Value = dtbl.Rows[i]["batchNo"];
                }

                foreach (DataGridViewRow dgvRowObj in dgvProductCreation.Rows)
                {
                    if (!dgvRowObj.IsNewRow)
                    {

                        DataGridViewCellEventArgs dgvArg = new DataGridViewCellEventArgs(0, dgvRowObj.Index);
                        CheckingForIncompleteRowInGrid(dgvArg);
                    }
                }
                dgvProductCreation.Focus();
                dgvProductCreation.CurrentCell = dgvProductCreation.Rows[0].Cells[1];
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Function to Edit stockposting table
        /// </summary>
        public void StockPostingTableEditFill()
        {

            try
            {
                StockPostingSP spStockPosting = new StockPostingSP();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                BatchSP spBatch = new BatchSP();
                for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
                {
                    infoStockPosting.StockPostingId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtstockpostId"].Value);
                    infoStockPosting.AgainstInvoiceNo = string.Empty;
                    infoStockPosting.AgainstVoucherNo = string.Empty;
                    infoStockPosting.Date = PublicVariables._dtCurrentDate;
                    infoStockPosting.AgainstVoucherTypeId = 0;
                    infoStockPosting.InvoiceNo = Convert.ToString(decProductIdForEdit);
                    infoStockPosting.VoucherNo = Convert.ToString(decProductIdForEdit);
                    infoStockPosting.VoucherTypeId = 2;

                    infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value);
                    infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value);
                    infoStockPosting.OutwardQty = 0;
                    infoStockPosting.ProductId = decProductIdForEdit;

                    infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value);
                    infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoStockPosting.Extra1 = string.Empty;
                    infoStockPosting.Extra2 = string.Empty;
                    infoStockPosting.ExtraDate = DateTime.Now;
                    if (!dgvProductCreation.Columns["dgvcmbrack"].Visible)
                    {
                        infoStockPosting.RackId = 1;
                    }
                    else
                    {
                        infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value);
                    }

                    if (!dgvProductCreation.Columns["dgvcmbtgodown"].Visible)
                    {
                        infoStockPosting.GodownId = 1;
                    }
                    else
                    {
                        infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value);
                    }

                    if (cmbAllowBatch.SelectedIndex == 0)
                    {
                        if (isBatchRemoved)
                        {
                            infoStockPosting.BatchId = spBatch.BatchIdForStockPosting(decProductIdForEdit);
                        }
                        else
                        {
                            int inId = spStockPosting.ReturnBatchIdFromStockPosting(decProductIdForEdit);
                            infoStockPosting.BatchId = inId;
                        }

                    }
                    else
                    {
                        infoStockPosting.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value);
                    }

                    isStpUpdated = spStockPosting.StockPostingEdit(infoStockPosting);


                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }



        }
Exemplo n.º 13
0
        /// <summary>
        /// On cellendedit of dgvProduct
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            ProductSP SpProduct = new ProductSP();
            try
            {
                if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductName")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString().Trim() != string.Empty)
                    {
                        string strProductName = Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value);
                        ProductInfo infoProduct = SpProduct.ProductViewByName(strProductName);
                        if (infoProduct.ProductCode != null && infoProduct.ProductCode != string.Empty)
                        {
                            TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
                            SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = infoProduct.ProductId;
                            
                            
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate);
                            DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces);
                            dtblUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), e.RowIndex);
                            dtblbatchViewAll = SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, e.RowIndex);
                            BatchSP spBatch = new BatchSP();
                            decimal decBatchId = spBatch.BatchIdViewByProductId(infoProduct.ProductId);
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = decBatchId;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;
                            if (infoProduct.PartNo != string.Empty)
                            {
                                dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo;
                            }
                            else
                            {
                                if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                                {
                                    decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value);
                                    dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = SpProduct.BarcodeViewByBatchId(decBatchId);
                                }
                            }
                            IsDoAfterFill = true;
                            UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                            DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString());
                            if (dtblUnitByProduct.Rows.Count > 0)
                            {
                                foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                                {
                                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                                    {
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                        if (IsDoAfterFill)
                                        {
                                            decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                            decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate,PublicVariables._inNoOfDecimalPlaces);
                                        }
                                    }
                                }
                            }

                            decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                            {
                                if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0)
                                {
                                    dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                                }
                            }

                        }
                        else
                        {
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty;
                        }
                            AmountCalculation("dgvtxtQty", e.RowIndex);
                            TotalAmountCalculation();
                    }
                    else
                    {
                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                    }
                }
                if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtBarcode")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString().Trim() != string.Empty)
                    {
                        DataTable dtblProductdDetails = new DataTable();
                        string strBarcode = (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value.ToString());
                        dtblProductdDetails = SpProduct.ProductDetailsCoreespondingToBarcode(strBarcode);
                        
                        if (dtblProductdDetails.Rows.Count > 0)
                        {
                            TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
                            SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
                            
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = dtblProductdDetails.Rows[0]["productCode"].ToString();
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = dtblProductdDetails.Rows[0]["productId"].ToString();
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = dtblProductdDetails.Rows[0]["productName"].ToString();
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(Convert.ToDecimal(dtblProductdDetails.Rows[0]["SalesRate"].ToString()));

                            DefaultRate = Math.Round(Convert.ToDecimal(dtblProductdDetails.Rows[0]["purchaseRate"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                            dtblUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, dtblProductdDetails.Rows[0]["productId"].ToString(), e.RowIndex);
                            dtblbatchViewAll = SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(dtblProductdDetails.Rows[0]["productId"].ToString()), e.RowIndex);
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtblProductdDetails.Rows[0]["batchId"].ToString());
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtblProductdDetails.Rows[0]["unitId"].ToString());


                            IsDoAfterFill = true;
                            UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                            DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString());
                            if (dtblUnitByProduct.Rows.Count > 0)
                            {
                                foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                                {
                                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                                    {
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                        if (IsDoAfterFill)
                                        {
                                            decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                            decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces);
                                        }
                                    }
                                }
                            }
                            decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(Convert.ToDecimal(dtblProductdDetails.Rows[0]["productId"].ToString()), PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                            {
                                if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0)
                                {
                                    dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                                }
                            }

                        }
                        else
                        {
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty;
                        }
                        AmountCalculation("dgvtxtQty", e.RowIndex);
                        TotalAmountCalculation();
                    }
                    else
                    {
                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                    }
                }
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtProductCode")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString().Trim() != string.Empty)
                    {
                        ProductInfo infoProduct = new ProductInfo();
                        string strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString();
                        infoProduct = SpProduct.ProductViewByCode(strProductCode);
                        if (infoProduct.ProductId != 0)
                        {
                            TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
                            SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = infoProduct.ProductId;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces);
                            DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces);

                            dtblUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), e.RowIndex);
                            dtblbatchViewAll = SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, e.RowIndex);

                            BatchSP spBatch = new BatchSP();
                            decimal decBatchId = spBatch.BatchIdViewByProductId(infoProduct.ProductId);
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = decBatchId;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;

                            if (infoProduct.PartNo != string.Empty)
                            {
                                dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo;
                            }
                            else
                            {
                                if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                                {
                                    decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value);
                                    dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = SpProduct.BarcodeViewByBatchId(decBatchId);
                                }
                            }
                            IsDoAfterFill = true;
                            UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                            DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString());
                            if (dtblUnitByProduct.Rows.Count > 0)
                            {
                                foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                                {
                                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                                    {
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                        if (IsDoAfterFill)
                                        {
                                            decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                            decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces);
                                        }
                                    }
                                }
                            }
                            decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                            if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                            {
                                if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0)
                                {
                                    dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                                }
                            }
                        }
                        else
                        {
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtAmount"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = string.Empty;
                            dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value = string.Empty;
                        }
                        AmountCalculation("dgvtxtQty", e.RowIndex);
                        TotalAmountCalculation();
                    }
                }
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty)
                    {
                        DefaultRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value);
                    }
                }
                CheckInvalidEntriesInDataGridProduct(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:56" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Function to call frmProductSearchPopup form to select and view product
        /// </summary>
        /// <param name="frmProductSearchPopup"></param>
        /// <param name="decproductId"></param>
        /// <param name="decCurrentRowIndex"></param>
        public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex)
        {
            ProductSP SpProduct = new ProductSP();
            ProductInfo infoProduct = new ProductInfo();
            try
            {
                this.Enabled = true;
                this.BringToFront();

                this.frmProductSearchPopupObj = frmProductSearchPopup;
                int inCurrentRowIndex = dgvProduct.CurrentRow.Index;
                dgvProduct.Rows.Add();
                if (decproductId != 0)
                {
                    infoProduct = SpProduct.ProductView(decproductId);


                    TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill();
                    SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
                    dgvProduct.Rows[inCurrentRowIndex].Cells["ProductId"].Value = infoProduct.ProductId;
                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(infoProduct.SalesRate, PublicVariables._inNoOfDecimalPlaces);
                    DefaultRate = Math.Round(infoProduct.PurchaseRate, PublicVariables._inNoOfDecimalPlaces);

                    dtblUnitViewAll = transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, infoProduct.ProductId.ToString(), inCurrentRowIndex);
                    dtblbatchViewAll = SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, infoProduct.ProductId, inCurrentRowIndex);

                    BatchSP spBatch = new BatchSP();
                    decimal decBatchId = spBatch.BatchIdViewByProductId(infoProduct.ProductId);
                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value = decBatchId;
                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;

                    if (infoProduct.PartNo != string.Empty)
                    {
                        dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = infoProduct.PartNo;
                    }
                    else
                    {
                        if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                        {
                            decBatchId = Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbBatch"].Value);
                            dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtBarcode"].Value = SpProduct.BarcodeViewByBatchId(decBatchId);
                        }
                    }
                    IsDoAfterFill = true;
                    UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                    DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[inCurrentRowIndex].Cells["ProductId"].Value.ToString());
                    if (dtblUnitByProduct.Rows.Count > 0)
                    {
                        foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                        {
                            if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                            {
                                dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                if (IsDoAfterFill)
                                {
                                    decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                    decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                    dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, PublicVariables._inNoOfDecimalPlaces);
                                }
                            }
                        }
                    }
                    decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(infoProduct.ProductId, PublicVariables._dtCurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                    if (dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                    {
                        if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value) != 0)
                        {
                            dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[inCurrentRowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                        }
                    }
                    dgvProduct.Rows[inCurrentRowIndex].HeaderCell.Value = "X";
                    dgvProduct.Rows[inCurrentRowIndex].HeaderCell.Style.ForeColor = Color.Red;
                }
                frmProductSearchPopupObj.Close();
                frmProductSearchPopupObj = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Function to add data to StockTable With Batch
        /// </summary>
        public void BatchTableWithStockAndProductBatchFill()
        {

            try
            {
                BatchSP spBatch = new BatchSP();
                BatchInfo infoBatch = new BatchInfo();
                StockPostingSP spStockPosting = new StockPostingSP();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
                {

                    infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
                    infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
                    infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
                    if (btnSave.Text == "Update")
                    {
                        infoBatch.ProductId = decProductIdForEdit;
                    }
                    else
                    {
                        infoBatch.ProductId = decSaveProduct;
                    }
                    infoBatch.Extra1 = string.Empty;
                    infoBatch.Extra2 = string.Empty;
                    infoBatch.ExtraDate = DateTime.Now;
                    infoBatch.narration = string.Empty;
                    infoBatch.barcode = Convert.ToString(spBatch.AutomaticBarcodeGeneration());
                    decBatchId = spBatch.BatchAddReturnIdentity(infoBatch);


                    infoStockPosting.AgainstInvoiceNo = string.Empty;
                    infoStockPosting.AgainstVoucherNo = string.Empty;
                    infoStockPosting.Date = PublicVariables._dtCurrentDate;
                    infoStockPosting.AgainstVoucherTypeId = 0;
                    infoStockPosting.InvoiceNo = Convert.ToString(decSaveProduct);
                    infoStockPosting.VoucherNo = Convert.ToString(decSaveProduct);
                    infoStockPosting.VoucherTypeId = 2;

                    infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value);
                    infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value);
                    infoStockPosting.OutwardQty = 0;
                    infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value);
                    infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoStockPosting.Extra1 = string.Empty;
                    infoStockPosting.Extra2 = string.Empty;
                    infoStockPosting.ExtraDate = DateTime.Now;
                    if ((dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Visible) == false)
                    {
                        infoStockPosting.RackId = 1;
                    }
                    else
                    {
                        infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value);
                    }
                    if ((dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Visible) == false)
                    {
                        infoStockPosting.GodownId = 1;
                    }
                    else
                    {
                        infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value);
                    }
                    if (btnSave.Text == "Update")
                    {
                        infoStockPosting.ProductId = decProductIdForEdit;
                    }
                    else
                    {
                        infoStockPosting.ProductId = decSaveProduct;
                    }
                    if (cmbAllowBatch.SelectedIndex == 0)
                    {
                        infoStockPosting.BatchId = 0;
                    }
                    else
                    {
                        infoStockPosting.BatchId = decBatchId;
                    }


                    decCheck = spStockPosting.StockPostingAdd(infoStockPosting);


                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:18" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Function for Delete Rows From tbl_StockPosting Or tbl_Batch
        /// </summary>
        public void RemoveRows()
        {

            try
            {

                foreach (var strId in lstArrOfRemove)
                {
                    decimal decDeleteId = Convert.ToDecimal(strId);

                    StockPostingSP spStockPosting = new StockPostingSP();
                    isRowRemoved = spStockPosting.StpDeleteForRowRemove(decDeleteId);
                }
                foreach (var strBatchId in lstArrOfRemoveFromBatchTable)
                {
                    decimal decDeleteId = Convert.ToDecimal(strBatchId);
                    BatchSP spBatch = new BatchSP();
                    spBatch.BatchDelete(decDeleteId);
                }
                foreach (var strStockPostingId in lstArrOfRemoveFromStockPosting)
                {
                    decimal decDeleteId = Convert.ToDecimal(strStockPostingId);

                    StockPostingSP spStockPosting = new StockPostingSP();
                    isRowRemoved = spStockPosting.StpDeleteForRowRemove(decDeleteId);
                }
                foreach (var strBatchRemoveId in lststrArrBatchRemove)
                {
                    decimal decDeleteId = Convert.ToDecimal(strBatchRemoveId);
                    BatchSP spBatch = new BatchSP();
                    spBatch.BatchDelete(decDeleteId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:68" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemplo n.º 17
0
        /// <summary>
        /// Function to save data to BatchTable While Updating
        /// </summary>
        public void BatchTableEditFill()
        {

            try
            {
                BatchSP spBatch = new BatchSP();
                BatchInfo infoBatch = new BatchInfo();
                for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
                {
                    infoBatch.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value);
                    infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
                    infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
                    infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
                    infoBatch.ProductId = decProductIdForEdit;
                    infoBatch.Extra1 = string.Empty;
                    infoBatch.Extra2 = string.Empty;
                    infoBatch.ExtraDate = DateTime.Now;
                    infoBatch.narration = string.Empty;
                    isBatchUpdated = spBatch.BatchEditForProductEdit(infoBatch);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Function to check existence of batch no
 /// </summary>
 /// <param name="e"></param>
 public void BatchNoExistenceChecking(DataGridViewCellEventArgs e)
 {
     try
     {
         BatchSP spBatch = new BatchSP();
         string strBatchNo = Convert.ToString(dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatch"].Value);
         decBatchId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatchId"].Value);
         bool isOk = spBatch.BatchNameExistenceChecking(strBatchNo, decBatchId);
         if (!isOk)
         {
             Messages.InformationMessage("Batch No already exist");
             dgvProductCreation.CurrentCell = dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatch"];
             dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatch"].Value = "";
             dgvProductCreation.BeginEdit(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 19
0
 /// <summary>
 /// Grid view Cell Enter for set editmode and set basics of unit conversion
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProduct_CellEnter(object sender, DataGridViewCellEventArgs e)
 {
     decimal decGodownId = 0;
     try
     {
         if (dgvProduct.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewComboBoxCell)
         {
             dgvProduct.EditMode = DataGridViewEditMode.EditOnEnter;
         }
         else
         {
             dgvProduct.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
         }
         if (e.RowIndex != -1 && e.ColumnIndex != -1)
         {
             if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
             {
                 if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
                 {
                     if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                     {
                         if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString() != string.Empty)
                         {
                             decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                             decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value.ToString());
                         }
                     }
                 }
             }
             if (dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value != null)
             {
                 if (dgvProduct.CurrentRow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
                 {
                     BatchSP spBatch = new BatchSP();
                     decimal decBatchId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbBatch"].Value);
                     string strBarcode = spBatch.ProductBatchBarcodeViewByBatchId(decBatchId);
                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode;
                 }
             }
             if (e.ColumnIndex == dgvProduct.Columns["dgvcmbRack"].Index)
             {
                 if (dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value != null)
                 {
                     if (dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value.ToString() != string.Empty)
                     {
                         if (dgvProduct.CurrentRow.Cells["dgvcmbRack"].Value == null || dgvProduct.CurrentRow.Cells["dgvcmbRack"].Value.ToString() == string.Empty)
                         {
                             decGodownId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value);
                             RackComboFill1(decGodownId, e.RowIndex, e.ColumnIndex);
                         }
                     }
                 }
             }
         }
         CheckInvalidEntries(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN49:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Function for New Row Added To tbl_Batch
        /// </summary>
        /// <param name="inI"></param>
        public void BatchTableNewRows(int inI)
        {

            try
            {
                BatchSP spBatch = new BatchSP();
                BatchInfo infoBatch = new BatchInfo();

                infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
                infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
                infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
                infoBatch.ProductId = decProductIdForEdit;
                infoBatch.Extra1 = string.Empty;
                infoBatch.Extra2 = string.Empty;
                infoBatch.ExtraDate = DateTime.Now;
                infoBatch.narration = string.Empty;
                infoBatch.barcode = Convert.ToString(spBatch.AutomaticBarcodeGeneration());
                decimal decId = spBatch.BatchAddReturnIdentity(infoBatch);
                //decimal decId = spBatch.StockPostingAdd(infoBatch);
                dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decId;


            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:73" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Function to call frmProductSearchPopup form to select and view Product created 
        /// </summary>
        /// <param name="frmProductSearchPopup"></param>
        /// <param name="decproductId"></param>
        /// <param name="decCurrentRowIndex"></param>
        public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex)
        {
            try
            {
                base.Show();
                this.frmProductSearchPopupObj = frmProductSearchPopup;
                DataTable dtbl = new DataTable();
                UnitConvertionSP spUnitConversion = new UnitConvertionSP();
                ProductInfo infoProduct = new ProductInfo();
                BatchSP spBatch = new BatchSP();
                infoProduct = new ProductSP().ProductView(decproductId);
                dgvProduct.Rows.Add();
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductId"].Value = decproductId.ToString();
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
                UnitComboFill1(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbUnit"].ColumnIndex);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbUnit"].Value = infoProduct.UnitId;
                GridGodownComboFill(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbGodown"].ColumnIndex);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbGodown"].Value = infoProduct.GodownId;
                RackComboFill1(infoProduct.GodownId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbRack"].ColumnIndex);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbRack"].Value = infoProduct.RackId;
                BatchComboFill(decproductId, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index, dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].ColumnIndex);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].Value = spBatch.BatchIdViewByProductId(decproductId);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtBarcode"].Value = spBatch.ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvcmbBatch"].Value.ToString()));
                dtbl = spUnitConversion.DGVUnitConvertionRateByUnitId(infoProduct.UnitId, infoProduct.ProductName);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[0]["unitconversionId"].ToString();
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[0]["conversionRate"].ToString();
                decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtConversionRate"].Value.ToString());
                AmountCalculation("dgvtxtQty", dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Index);
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].Cells["dgvtxtRate"].Value = infoProduct.SalesRate.ToString();
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].HeaderCell.Value = "X";
                dgvProduct.Rows[Convert.ToInt32(decCurrentRowIndex.ToString())].HeaderCell.Style.ForeColor = Color.Red;
                TotalAmountCalculation();
                frmProductSearchPopupObj.Close();
                frmProductSearchPopupObj = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemplo n.º 22
0
        /// <summary>
        /// Function to fill product,product code autocompletion 
        /// </summary>
        /// <param name="isBatchName"></param>
        /// <param name="editControl"></param>
        public void FillBatch(bool isBatchName, DataGridViewTextBoxEditingControl editControl)
        {
            try
            {
                BatchSP spBatch = new BatchSP();
                DataTable dtblBatch = new DataTable();
                Batch = spBatch.BatchViewAllWithoutNA();

            }
            catch (Exception ex)
            {
                MessageBox.Show("PO4:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemplo n.º 23
0
 /// <summary>
 /// Sales grid cell leave event to calculate the basic functions and calculation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvSalesInvoice_CellLeave(object sender, DataGridViewCellEventArgs e)
 {
     if (IsSetGridValueChange == true)
     {
         BatchSP spBatch = new BatchSP();
         UnitConvertionSP spUnitConversion = new UnitConvertionSP();
         DataTable dtblUnitConversion = new DataTable();
         decimal decBatchId = 0;
         string strBarcode = string.Empty;
         try
         {
             if (e.RowIndex != -1 && e.ColumnIndex != -1)
             {
                 if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null)
                 {
                     if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty)
                     {
                         if (dgvSalesInvoice.RowCount > 1)
                         {
                             if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null)
                             {
                                 try
                                 {
                                     if (decimal.Parse(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) > 0)
                                     {
                                         if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null)
                                         {
                                             if (decimal.Parse(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()) > decimal.Parse(dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString()))
                                             {
                                                 dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value = dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString();
                                                 if (decDeliveryNoteQty < decimal.Parse(dtblDeliveryNoteDetails.Rows[e.RowIndex]["qty"].ToString()))
                                                 {
                                                     dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value = decDeliveryNoteQty;
                                                     decDeliveryNoteQty = 0;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 catch (Exception)
                                 {
                                 }
                             }
                             if (dgvSalesInvoice.Columns[e.ColumnIndex].Name == "dgvtxtSalesInvoicembUnitName")
                             {
                                 if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoicembUnitName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString() != string.Empty)
                                 {
                                     UnitConversionCalc(e.RowIndex);
                                 }
                             }
                             if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString() != string.Empty
                                 || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty
                                 || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty
                                || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty)
                             {
                                 DiscountCalculation(e.RowIndex, e.ColumnIndex);
                             }
                             if (dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbSalesInvoiceTaxName" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceGrossValue" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceDiscountPercentage")
                             {
                                 if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Visible)
                                 {
                                     if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Value != null && (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value != null || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value != null))
                                     {
                                         if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString() != string.Empty && (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString() != string.Empty || dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString() != string.Empty))
                                         {
                                             {
                                                 taxAndGridTotalAmountCalculation(e.RowIndex);
                                             }
                                         }
                                     }
                                 }
                                 else
                                 {
                                     taxAndGridTotalAmountCalculation(e.RowIndex);
                                 }
                             }
                             if (dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceRate" || dgvSalesInvoice.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvtxtSalesInvoiceQty")
                             {
                                 if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null)
                                 {
                                     if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString() != string.Empty)
                                     {
                                         {
                                             GrossValueCalculation(e.RowIndex);
                                         }
                                     }
                                 }
                             }
                         }
                         if (e.ColumnIndex == dgvSalesInvoice.Columns["dgvcmbSalesInvoiceBatch"].Index)
                         {
                             if (dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value != null)
                             {
                                 if (dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty && dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != "0")
                                 {
                                     decBatchId = Convert.ToDecimal(dgvSalesInvoice.CurrentRow.Cells["dgvcmbSalesInvoiceBatch"].Value.ToString());
                                     strBarcode = spBatch.ProductBatchBarcodeViewByBatchId(decBatchId);
                                     dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceBarcode"].Value = strBarcode;
                                     if (dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceProductId"].Value != null)      // here get product rate for sales(standard rate)
                                     {
                                         getProductRate(e.RowIndex, Convert.ToDecimal(dgvSalesInvoice.CurrentRow.Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()), decBatchId);
                                         UnitConversionCalc(e.RowIndex);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value != null && dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString() != string.Empty)
                 {
                     if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceConversionRate"].Value != null)
                     {
                         decCurrentConversionRate = Convert.ToDecimal(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceConversionRate"].Value.ToString());
                     }
                     if (dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value != null)
                     {
                         decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[e.RowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString());
                     }
                 }
                 CheckInvalidEntries(e);
                 SiGridTotalAmountCalculation();
                 CalculateAmountFromGrid(e.RowIndex, e, e.ColumnIndex);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("SI: 105" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Function to save batch
        /// </summary>
        public void BatchTableFill()
        {

            try
            {
                BatchSP spBatch = new BatchSP();
                BatchInfo infoBatch = new BatchInfo();
                for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++)
                {
                    infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value);
                    infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value);
                    infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString();
                    infoBatch.barcode = Convert.ToString(spBatch.AutomaticBarcodeGeneration());
                    if (btnSave.Text == "Update")
                    {
                        infoBatch.ProductId = decProductIdForEdit;
                    }
                    else
                    {
                        infoBatch.ProductId = decSaveProduct;
                    }
                    infoBatch.Extra1 = string.Empty;
                    infoBatch.Extra2 = string.Empty;
                    infoBatch.ExtraDate = DateTime.Now;
                    infoBatch.narration = string.Empty;
                    decBatchId = spBatch.BatchAddAndDelete(infoBatch, decProductIdForEdit);
                    dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value = decBatchId;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Get the Product details from the Product creation form
        /// </summary>
        /// <param name="decproductId"></param>
        public void ReturnFromProductCreation(decimal decproductId)
        {
            try
            {
                ProductInfo infoProduct = new ProductInfo();
                ProductSP spProduct = new ProductSP();
                BatchSP spBatch = new BatchSP();
                DataTable dtbl = new DataTable();
                UnitConvertionSP spUnitConversion = new UnitConvertionSP();
                this.Enabled = true;
                this.BringToFront();
                if (decproductId != 0)
                {
                    infoProduct = spProduct.ProductView(decproductId);
                    strProductCode = infoProduct.ProductCode;

                    if (IsdgvConsuption)
                    {
                        int inCurrentRowIndex = dgvConsumption.CurrentRow.Index;
                        dgvConsumption.Rows.Add();
                        ProductDetailsFillConsumption(strProductCode, inCurrentRowIndex, "ProductCode");
                    }

                    else
                    {
                        int inProductionRowIndex = dgvProduction.CurrentRow.Index;
                        dgvProduction.Rows.Add();
                        ProductDetailsFillProduction(strProductCode, inProductionRowIndex, "ProductCode");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Function to save batch
        /// </summary>

        public void BatchWithBarCode()
        {
            BatchSP spBatch = new BatchSP();
            BatchInfo infoBatch = new BatchInfo();
            Int32 inBarcode = spBatch.AutomaticBarcodeGeneration();
            infoBatch.BatchNo = "NA";
            infoBatch.ExpiryDate = DateTime.Now;
            infoBatch.ManufacturingDate = DateTime.Now;
            infoBatch.partNo = txtPartNo.Text.Trim();
            if (btnSave.Text == "Update")
            {
                infoBatch.ProductId = decProductIdForEdit;
            }
            else
            {
                infoBatch.ProductId = decSaveProduct;
            }
            infoBatch.narration = string.Empty;
            infoBatch.ExtraDate = DateTime.Now;
            infoBatch.barcode = Convert.ToString(inBarcode);
            infoBatch.Extra1 = string.Empty;
            infoBatch.Extra2 = string.Empty;
            inBatchIdWithPartNoNA = spBatch.BatchAddWithBarCode(infoBatch);

        }
Exemplo n.º 27
0
        /// <summary>
        /// dgvProduction grid cell valuechange event to calculate the basic functions and calculation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProduction_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (IsSetGridValueChange)
                {
                    if (e.RowIndex != -1 && e.ColumnIndex != -1)
                    {
                        if (dgvProduction.RowCount > 1)
                        {
                            if (dgvProduction.Columns[e.ColumnIndex].Name == "dgvcmbProductionunitId")
                            {
                                if (dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value != null && dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value.ToString() != string.Empty)
                                {
                                    UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                                    DataTable dtblUnitByProduct = new DataTable();
                                    dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionProductId"].Value.ToString());
                                    foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                                    {
                                        if (dgvProduction.Rows[e.RowIndex].Cells["dgvcmbProductionunitId"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                                        {
                                            dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionunitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                            dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());

                                            decimal decNewConversionRate = Convert.ToDecimal(dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionConversionRate"].Value.ToString());
                                            decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                            dgvProduction.Rows[e.RowIndex].Cells["dgvtxtProductionRate"].Value = Math.Round(decNewRate, 2);
                                        }
                                    }
                                    TotalAmountCalculationProduction("", e.RowIndex);
                                }
                            }

                            if (e.ColumnIndex == dgvProduction.Columns["dgvcmbProductionBatch"].Index)
                            {
                                BatchSP spBatch = new BatchSP();
                                decimal decBatchId = 0;
                                string strBarcode = string.Empty;
                                if (dgvProduction.CurrentRow.Cells["dgvtxtProductionProductId"].Value != null)
                                {
                                    if (dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value != null)
                                    {
                                        if (dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value.ToString() != string.Empty &&
                                            dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value.ToString() != "0")
                                        {
                                            decBatchId = Convert.ToDecimal(dgvProduction.CurrentRow.Cells["dgvcmbProductionBatch"].Value);
                                            strBarcode = spBatch.ProductBatchBarcodeViewByBatchId(decBatchId);
                                            dgvProduction.CurrentRow.Cells["dgvtxtProductionBarcode"].Value = strBarcode;
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:81" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Work on dgvProductCreation CellEndEdit event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProductCreation_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {

            try
            {
                if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvtxtbatch")
                {
                    string strBatch = dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null ? "" : dgvProductCreation.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                    if (strBatch != "")
                    {
                        BatchSP spBatch = new BatchSP();
                        DataTable dtbl = new DataTable();

                        dtbl = spBatch.BatchViewByName(strBatch, decId);
                        if (dtbl.Rows.Count != 0)
                        {
                            //dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtbatchId"].Value = Convert.ToDecimal(dtbl.Rows[0]["batchId"]);
                            dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = dtbl.Rows[0]["expiryDate"];
                            dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = dtbl.Rows[0]["manufacturingDate"];
                        }
                    }
                    else
                    {
                        dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxtExpDate"].Value = string.Empty;
                        dgvProductCreation.Rows[e.RowIndex].Cells["dgvtxManfDate"].Value = string.Empty;
                    }
                }
                if (dgvProductCreation.Columns[e.ColumnIndex].Name == "dgvcmbtgodown")
                {
                    RackSP spRack = new RackSP();
                    RackInfo infoRack = new RackInfo();
                    DataTable dtblRack = new DataTable();
                    decimal decGodownId = Convert.ToDecimal(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbtgodown"].Value);
                    dtblRack = spRack.RackNamesCorrespondingToGodownId(decGodownId);
                    DataRow drow = dtblRack.NewRow();
                    drow["rackName"] = string.Empty;
                    drow["rackId"] = 0;
                    dtblRack.Rows.InsertAt(drow, 0);
                    DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dgvProductCreation.Rows[e.RowIndex].Cells["dgvcmbrack"]);
                    cell.DataSource = dtblRack;
                    cell.ValueMember = "rackId";
                    cell.DisplayMember = "rackName";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Function to fill batch combobox
 /// </summary>
 public void BatchComboFill()
 {
     try
     {
         BatchSP spBatch = new BatchSP();
         DataTable dtblBatch = new DataTable();
         dtblBatch = spBatch.BatchViewAll();
         dgvcmbConsumptionBatch.DataSource = dtblBatch;
         dgvcmbConsumptionBatch.ValueMember = "batchId";
         dgvcmbConsumptionBatch.DisplayMember = "batchNo";
         dgvcmbProductionBatch.DataSource = dtblBatch;
         dgvcmbProductionBatch.ValueMember = "batchId";
         dgvcmbProductionBatch.DisplayMember = "batchNo";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 30
0
 /// <summary>
 /// Function to Fill Product Details in grid
 /// </summary>
 /// <param name="strProductCode"></param>
 /// <param name="rowIndex"></param>
 private void FillProductDetails(string strProductCode, int rowIndex)
 {
     try
     {
         ProductInfo infoProductFill = new ProductInfo();
         infoProductFill = new ProductSP().ProductViewByCode(strProductCode);
         UnitConvertionSP SPUnitConversion = new UnitConvertionSP();
         BatchSP spBatch = new BatchSP();
         ProductSP spProduct = new ProductSP();
         StockPostingSP spStockPosting = new StockPostingSP();
         DataTable dtbl = new DataTable();
         decimal decCurrentConversionRate = 0;
         if (infoProductFill.ProductId != 0)
         {
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductId"].Value = infoProductFill.ProductId;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductCode"].Value = infoProductFill.ProductCode;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductName"].Value = infoProductFill.ProductName;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbGodown"].Value = infoProductFill.GodownId;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbRack"].Value = infoProductFill.RackId;
             UnitComboFill(infoProductFill.ProductId, rowIndex, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbUnit"].ColumnIndex);
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbUnit"].Value = infoProductFill.UnitId;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtrate"].Value = Math.Round(infoProductFill.PurchaseRate, PublicVariables._inNoOfDecimalPlaces);
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(new UnitConvertionSP().UnitconversionIdViewByUnitIdAndProductId(infoProductFill.UnitId, infoProductFill.ProductId));
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value = SPUnitConversion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value.ToString()));
             BatchComboFill(infoProductFill.ProductId, rowIndex, dgvPurchaseReturn.CurrentRow.Cells["dgvcmbBatch"].ColumnIndex);
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbBatch"].Value = spStockPosting.BatchViewByProductId(Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtproductId"].Value));
             dtbl = SPUnitConversion.DGVUnitConvertionRateByUnitId(infoProductFill.UnitId, infoProductFill.ProductName);
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[0]["unitconversionId"].ToString();
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[0]["conversionRate"].ToString();
             decCurrentConversionRate = Convert.ToDecimal(dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
             //dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtqty"].Value = 0;
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbTax"].Value = infoProductFill.TaxId;
             AmountCalculation("dgvtxtqty", rowIndex);
             decimal decProdtId = infoProductFill.ProductId;
             decBatchId = spStockPosting.BatchViewByProductId(decProdtId);
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvcmbBatch"].Value = decBatchId;
             string strBarcode = Convert.ToString(spProduct.BarcodeViewByBatchId(decBatchId));
             dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtbarcode"].Value = strBarcode;
             if (dgvPurchaseReturn.Rows[rowIndex + 1].Cells["dgvtxtproductCode"].Selected == true)
             {
                 dgvPurchaseReturn.Rows[rowIndex].Cells["dgvtxtqty"].Selected = true;
                 dgvPurchaseReturn.Rows[rowIndex + 1].Selected = false;
                 dgvPurchaseReturn.Rows[rowIndex].HeaderCell.Value = "X";
                 dgvPurchaseReturn.Rows[rowIndex].HeaderCell.Style.ForeColor = Color.Red;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }