/// <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);
            }
        }
        /// <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);

        }
        /// <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);
            }
        }
        /// <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);
            }
        }
Beispiel #5
0
 //Jamshi
 //public void SaveFunction()
 //{
 //    try
 //    {
 //        BatchSP spBatch = new BatchSP();
 //        BatchInfo infoBatch = new BatchInfo();
 //        infoBatch.BatchNo = txtBatchName.Text.Trim();
 //        infoBatch.ProductId = Convert.ToDecimal(cmbProduct.SelectedValue.ToString());
 //        infoBatch.ManufacturingDate = Convert.ToDateTime(txtMfgDate.Text);
 //        infoBatch.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
 //        infoBatch.narration = txtNarration.Text.Trim();
 //        infoBatch.Extra1 = string.Empty;
 //        infoBatch.Extra2 = string.Empty;
 //        if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false)
 //        {
 //            if (dtpMfgDate.Value <= dtpExpiryDate.Value)
 //            {
 //                spBatch.BatchAddParticularFields(infoBatch);
 //                Messages.SavedMessage();
 //                Clear();
 //            }
 //            else
 //            {
 //                Messages.InformationMessage(" Can't save batch with mfg date greater than expiry date");
 //                txtMfgDate.Select();
 //            }
 //        }
 //        else
 //        {
 //            Messages.InformationMessage(" Already exist");
 //            txtBatchName.Focus();
 //        }
 //    }
 //    catch (Exception ex)
 //    {
 //        MessageBox.Show("B1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
 //    }
 //}
 //public void EditFunction()
 //{
 //    try
 //    {
 //        BatchSP spBatch = new BatchSP();
 //        BatchInfo infoBatch = new BatchInfo();
 //        infoBatch.BatchNo = txtBatchName.Text.Trim();
 //        infoBatch.ProductId = Convert.ToDecimal(cmbProduct.SelectedValue.ToString());
 //        infoBatch.ManufacturingDate = Convert.ToDateTime(txtMfgDate.Text);
 //        infoBatch.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
 //        infoBatch.narration = txtNarration.Text.Trim();
 //        infoBatch.Extra1 = string.Empty;
 //        infoBatch.Extra2 = string.Empty;
 //        infoBatch.BatchId = decId;
 //        if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false)
 //        {
 //            spBatch.BatchEdit(infoBatch);
 //            Messages.UpdatedMessage();
 //            SearchClear();
 //            Clear();
 //        }
 //        else
 //        {
 //            Messages.InformationMessage("Already exists");
 //            txtBatchName.Focus();
 //        }
 //    }
 //    catch (Exception ex)
 //    {
 //        MessageBox.Show("B2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
 //    }
 //}
 /// <summary>
 /// Functin to save and update batch
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         if (txtBatchName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter batch name");
             txtBatchName.Focus();
         }
         else if (cmbProduct.SelectedIndex == -1)
         {
             Messages.InformationMessage("Select product");
             cmbProduct.Focus();
         }
         else
         {
             BatchSP spBatch = new BatchSP();
             BatchInfo infoBatch = new BatchInfo();
             infoBatch.BatchNo = txtBatchName.Text.Trim();
             infoBatch.ProductId = Convert.ToDecimal(cmbProduct.SelectedValue.ToString());
             infoBatch.ManufacturingDate = Convert.ToDateTime(txtMfgDate.Text);
             infoBatch.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
             infoBatch.narration = txtNarration.Text.Trim();
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             Int32 inBarcode = spBatch.AutomaticBarcodeGeneration(); // updated by jaseel
             infoBatch.barcode = Convert.ToString(inBarcode);
             if (btnSave.Text == "Save")
             {
                 //Jamshi
                 //if (PublicVariables.isMessageAdd)
                 //{
                 //    if (Messages.SaveMessage())
                 //    {
                 //        SaveFunction();
                 //    }
                 //}
                 //else
                 //{
                 //    SaveFunction();
                 //}
                 if (Messages.SaveConfirmation())
                 {
                     if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false)
                     {
                         if (dtpMfgDate.Value <= dtpExpiryDate.Value)
                         {
                             spBatch.BatchAddParticularFields(infoBatch);
                             Messages.SavedMessage();
                             Clear();
                         }
                         else
                         {
                             Messages.InformationMessage(" Can't save batch with mfg date greater than expiry date");
                             txtMfgDate.Select();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage(" Already exist");
                         txtBatchName.Focus();
                     }
                 }
             }
             else
             {
                 //Jamshi
                 //if (PublicVariables.isMessageEdit)
                 //{
                 //    if (Messages.UpdateMessage())
                 //    {
                 //        EditFunction();
                 //    }
                 //}
                 //else
                 //{
                 //    EditFunction();
                 //}
                 if (Messages.UpdateConfirmation())
                 {
                     infoBatch.BatchId = decId;
                     if (spBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false)
                     {
                         spBatch.BatchEdit(infoBatch);
                         Messages.UpdatedMessage();
                         SearchClear();
                         Clear();
                     }
                     else
                     {
                         Messages.InformationMessage("Already exists");
                         txtBatchName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("B1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         int inRowCount = dgvMultipleProductCreation.RowCount;
         BatchSP spBatch = new BatchSP();
         BatchInfo infoBatch = new BatchInfo();
         ProductSP spProduct = new ProductSP();
         ProductInfo infoProduct = new ProductInfo();
         UnitConvertionSP spUnitConvertion = new UnitConvertionSP();
         UnitConvertionInfo infoUnitConvertion = new UnitConvertionInfo();
         for (int i = 0; i < inRowCount - 1; i++)
         {
             infoProduct.GroupId = Convert.ToDecimal(cmbProductGroup.SelectedValue.ToString());
             infoProduct.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue.ToString());
             infoProduct.TaxId = Convert.ToDecimal(cmbTax.SelectedValue.ToString());
             if (cmbGoDown.SelectedIndex != -1)
             {
                 infoProduct.GodownId = Convert.ToDecimal(cmbGoDown.SelectedValue.ToString());
             }
             else
             {
                 infoProduct.GodownId = 0;
             }
             if (cmbRack.SelectedIndex != -1)
             {
                 infoProduct.RackId = Convert.ToDecimal(cmbRack.SelectedValue.ToString());
             }
             else
             {
                 infoProduct.RackId = 0;
             }
             infoProduct.MinimumStock = 0;
             infoProduct.MaximumStock = 0;
             infoProduct.ReorderLevel = 0;
             infoProduct.IsallowBatch = false;
             infoProduct.Ismultipleunit = false;
             infoProduct.IsBom = false;
             infoProduct.Isopeningstock = false;
             infoProduct.IsActive = true;
             infoProduct.IsshowRemember = false;
             infoProduct.Narration = string.Empty;
             infoProduct.Extra1 = string.Empty;
             infoProduct.Extra2 = string.Empty;
             infoProduct.PartNo = string.Empty;
             infoProduct.TaxapplicableOn = cmbTaxApplication.SelectedItem.ToString();
             infoProduct.ProductCode = dgvMultipleProductCreation.Rows[i].Cells["dgvtxtProductCode"].Value.ToString().Trim();
             infoProduct.ProductName = dgvMultipleProductCreation.Rows[i].Cells["dgvtxtProductName"].Value.ToString().Trim();
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbBrand"].Value != null)
             {
                 infoProduct.BrandId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbBrand"].Value.ToString());
             }
             else
             {
                 infoProduct.BrandId = 1;
             }
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbModel"].Value != null)
             {
                 infoProduct.ModelNoId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbModel"].Value.ToString());
             }
             else
             {
                 infoProduct.ModelNoId = 1;
             }
             if (dgvMultipleProductCreation.Rows[i].Cells["dgvcmbSize"].Value != null)
             {
                 infoProduct.SizeId = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvcmbSize"].Value.ToString());
             }
             else
             {
                 infoProduct.SizeId = 1;
             }
             infoProduct.PurchaseRate = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtPurchaseRate"].Value.ToString());
             infoProduct.SalesRate = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtSalesRate"].Value.ToString());
             infoProduct.Mrp = Convert.ToDecimal(dgvMultipleProductCreation.Rows[i].Cells["dgvtxtMRP"].Value.ToString());
             decIdentity = spProduct.ProductAdd(infoProduct);
             //...................................................................ADD UNIT TO UNIT CONVERSION TABLE...................................................................................//
             infoUnitConvertion.ProductId = decIdentity;
             infoUnitConvertion.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue.ToString());
             infoUnitConvertion.ConversionRate = 1;
             infoUnitConvertion.ExtraDate = DateTime.Now;
             infoUnitConvertion.Quantities = string.Empty;
             infoUnitConvertion.Extra1 = string.Empty;
             infoUnitConvertion.Extra2 = string.Empty;
             spUnitConvertion.UnitConvertionAdd(infoUnitConvertion);
             //...................................................................ADD BATCH TO BATCH TABLE...................................................................................//
             Int32 inBarcode = spBatch.AutomaticBarcodeGeneration();
             infoBatch.BatchNo = "NA";
             infoBatch.ExpiryDate = DateTime.Now;
             infoBatch.ManufacturingDate = DateTime.Now;
             infoBatch.partNo = string.Empty;
             infoBatch.ProductId = decIdentity;
             infoBatch.narration = string.Empty;
             infoBatch.ExtraDate = DateTime.Now;
             infoBatch.barcode = Convert.ToString(inBarcode);
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             spBatch.BatchAddWithBarCode(infoBatch);
         }
         Messages.SavedMessage();
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }