예제 #1
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         foreach (DataGridViewRow dgvRow in dgvChangeProductTax.Rows)
         {
             if (dgvRow.Cells["dgvtxtSelect"].Value != null)
             {
                 if ((bool)(dgvRow.Cells["dgvtxtSelect"].Value))
                 {
                     int inProductId = Convert.ToInt32(dgvChangeProductTax.Rows[dgvRow.Index].Cells["dgvtxtProductId"].Value.ToString());
                     ProductSP spProduct = new ProductSP();
                     ProductInfo infoProduct = new ProductInfo();
                     infoProduct.TaxId = Convert.ToInt32(cmbNewTaxType.SelectedValue.ToString());
                     infoProduct.ProductId = inProductId;
                     spProduct.ChangeProductTaxSave(infoProduct);
                     isDefault = false;
                 }
             }
         }
         Messages.SavedMessage();
         cmbSearchBy.Focus();
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("CPT 2 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #2
0
 /// <summary>
 /// Function to execute while calling from frmPriceList form to add new pricelist for the product
 /// </summary>
 /// <param name="decPricingLevel"></param>
 /// <param name="decProduct"></param>
 /// <param name="decPriceListId"></param>
 /// <param name="frmPriceList"></param>
 public void CallFromPriceListForPricingLevel(decimal decPricingLevel, decimal decProduct, decimal decPriceListId, frmPriceList frmPriceList)
 {
     try
     {
         ProductInfo infoProduct = new ProductInfo();
         ProductSP spProduct = new ProductSP();
         UnitSP spunit = new UnitSP();
         UnitInfo infoUnit = new UnitInfo();
         PriceListSP spPriceList = new PriceListSP();
         PriceListInfo infoPriceList = new PriceListInfo();
         PricingLevelSP spPricingLevel = new PricingLevelSP();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoProduct = spProduct.PriceListPopUpView(decProduct);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         decProduct = infoProduct.ProductId;
         decProductMain = infoProduct.ProductId;
         infoUnit = spunit.UnitViewForPriceListPopUp(decProduct);
         decUnitId = infoUnit.UnitId;
         txtUnitName.Text = infoUnit.UnitName;
         decPriceLevelId = infoPriceList.PricinglevelId;
         infoPricingLevel = spPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProduct, decUnitId);
         decPriceLevelId = infoPricingLevel.PricinglevelId;
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         if (txtPricingLevel.Text == string.Empty)
         {
             infoPricingLevel = spPricingLevel.PricingLevelView(decPricingLevel);
             txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         }
         decPricingLevelMain = infoPricingLevel.PricinglevelId;
         txtPricingLevel.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtProductName.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         txtRate.Focus();
         BatchUnderProductComboFill(decProduct);
         PriceListPopupGridFill();
         deca = decPriceListId;
         this.frmPriceListobj = frmPriceList;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PLP1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #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);
            }
        }
예제 #4
0
        /// <summary>
        /// Function to fill the grid based on the search keys
        /// </summary>
        public void GridFill()
        {
            try
            {
                string strComboText = string.Empty;
                DataTable dtbl = new DataTable();
                ProductSP spProduct = new ProductSP();
                ProductInfo infoProduct = new ProductInfo();
                if (cmbActive.Text == "Yes")
                {
                    strComboText = "True";
                }
                else if (cmbActive.Text == "No")
                {
                    strComboText = "False";
                }
                else
                {
                    cmbActive.SelectedIndex = 0;
                    strComboText = "All";
                }
                if (txtSalesRateFrom.Text == string.Empty && txtSalesRateTo.Text == string.Empty)
                {
                    txtSalesRateFrom.Text = "0";
                    txtSalesRateTo.Text = "0";
                }
                decimal decProductGroup = Convert.ToDecimal(cmbProductGroup.SelectedValue);
                string strProductName = txtProductName.Text.Trim();
                string strProductCode = txtProductCode.Text.Trim();
                decimal decSize = Convert.ToDecimal(cmbSize.SelectedValue);
                decimal decModelNo = Convert.ToDecimal(cmbModelNo.SelectedValue);
                decimal decBrand = Convert.ToDecimal(cmbBrand.SelectedValue);
                decimal decTax = Convert.ToDecimal(cmbTax.SelectedValue);
                string strTaxApplicable = cmbTaxApplicableOn.Text.Trim();
                decimal decSalesRateFrom = Convert.ToDecimal(txtSalesRateFrom.Text);
                decimal decSalesRateTo = Convert.ToDecimal(txtSalesRateTo.Text);

                dtbl = spProduct.ProductRegisterSearch(decProductGroup, strProductName, strProductCode, decSize, decModelNo, decBrand, decTax, strTaxApplicable, decSalesRateFrom, decSalesRateTo, strComboText);

                dgvProductRegister.DataSource = dtbl;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #5
0
 /// <summary>
 /// Function to call frmProductSearchPopup form to select and view a product
 /// </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();
     try
     {
         base.Show();
         this.frmProductSearchPopupObj = frmProductSearchPopup;
         infoProduct = spProduct.ProductView(decproductId);
         int inRowcount = dgvSalesInvoice.Rows.Count;
         for (int i = 0; i < inRowcount; i++)
         {
             if (i == decCurrentRowIndex)
             {
                 dgvSalesInvoice.Rows.Add();
                 dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].Value = infoProduct.ProductCode;
                 strProductCode = infoProduct.ProductCode;
                 ProductDetailsFill(strProductCode, i, "ProductCode");
             }
         }
         frmProductSearchPopupObj.Close();
         frmProductSearchPopupObj = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 59" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #6
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);
     }
 }
예제 #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);
     }
 }
예제 #8
0
        /// <summary>
        /// Function to get the Details
        /// </summary>
        public void DeliveryNoteDetails()
        {
            try
            {
                ProductInfo infoProduct = new ProductInfo();
                ProductSP spProduct = new ProductSP();
                DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                StockPostingSP spStockPosting = new StockPostingSP();
                DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
                UnitSP spUnit = new UnitSP();

                for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++)
                {
                    if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null)
                    {
                        if (cmbDeliveryMode.Text == "Against Order")
                        {
                            if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                            }
                            else
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        else if (cmbDeliveryMode.Text == "Against Quotation")
                        {
                            if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null)
                            {
                                infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                            }
                            else
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        else if (cmbDeliveryMode.Text == "NA")
                        {
                            infoDeliveryNoteDetails.OrderDetails1Id = 0;
                            infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                        }
                    }
                    else
                    {
                        if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value != null)
                        {
                            if (cmbDeliveryMode.Text == "Against Order")
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                            }
                            else if (cmbDeliveryMode.Text == "Against Quotation")
                            {
                                infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString());
                            }
                            else if (cmbDeliveryMode.Text == "NA")
                            {
                                infoDeliveryNoteDetails.OrderDetails1Id = 0;
                                infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                            }
                        }
                        else
                        {
                            infoDeliveryNoteDetails.OrderDetails1Id = 0;
                            infoDeliveryNoteDetails.QuotationDetails1Id = 0;
                        }
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null || dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() == string.Empty || Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) == 0)
                    {
                        infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                        infoProduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                        infoDeliveryNoteDetails.ProductId = infoProduct.ProductId;
                        infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                        infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value);
                        infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                        infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString());
                        infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString());
                        infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                        infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                        infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString());
                        infoDeliveryNoteDetails.Extra1 = string.Empty;
                        infoDeliveryNoteDetails.Extra2 = string.Empty;
                        spDeliveryNoteDetails.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails);
                    }
                    else
                    {
                        infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                        infoDeliveryNoteDetails.DeliveryNoteDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value);
                        infoProduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                        infoDeliveryNoteDetails.ProductId = infoProduct.ProductId;
                        infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());

                        if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) == 0)
                        {
                            infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                        }
                        else
                        {
                            infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(spUnit.UnitIdByUnitName(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].FormattedValue.ToString()));
                        }
                        infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                        infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString());
                        infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString());
                        infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                        infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                        infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString());
                        spDeliveryNoteDetails.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails);
                    }
                    infoStockPosting.Date = Convert.ToDateTime(txtDate.Text);
                    if (Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value) != 0)
                    {
                        if (cmbDeliveryMode.SelectedItem.ToString() != "NA")
                        {
                            if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null)
                            {
                                infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value);
                            }
                            else
                            {
                                infoStockPosting.VoucherTypeId = 0;
                            }
                            if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null)
                            {
                                infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString();
                            }
                            else
                            {
                                infoStockPosting.VoucherNo = string.Empty;
                            }
                            if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null)
                            {
                                infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString();
                            }
                            else
                            {
                                infoStockPosting.InvoiceNo = string.Empty;
                            }
                            if (decDeliveryNoteVoucherTypeId != 0)
                            {
                                infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId;
                            }
                            else
                            {
                                infoStockPosting.AgainstVoucherTypeId = 0;
                            }
                            if (strVoucherNo != string.Empty)
                            {
                                infoStockPosting.AgainstVoucherNo = strVoucherNo;
                            }
                            else
                            {
                                infoStockPosting.AgainstVoucherNo = string.Empty;
                            }
                            if (txtDeliveryNoteNo.Text != string.Empty)
                            {
                                infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text;
                            }
                            else
                            {
                                infoStockPosting.AgainstInvoiceNo = string.Empty;
                            }
                        }
                    }
                    else
                    {
                        infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text;
                        infoStockPosting.VoucherNo = strVoucherNo;
                        infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId;
                        infoStockPosting.AgainstVoucherTypeId = 0;
                        infoStockPosting.AgainstVoucherNo = "NA";
                        infoStockPosting.AgainstInvoiceNo = "NA";
                    }
                    infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId;
                    infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId;
                    infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId;
                    infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId;
                    infoStockPosting.RackId = infoDeliveryNoteDetails.RackId;
                    infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty;
                    infoStockPosting.Rate = infoDeliveryNoteDetails.Rate;
                    infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoStockPosting.Extra1 = string.Empty;
                    infoStockPosting.Extra2 = string.Empty;
                    spStockPosting.StockPostingAdd(infoStockPosting);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #9
0
        /// <summary>
        /// Function for Amount Calculations for Gross value, Net amount, Tax amount and Total amount
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="inIndexOfRow"></param>
        public void AmountCalculation(string columnName, int inIndexOfRow)
        {
            try
            {
                string strTaxRate = string.Empty;
                decimal decTaxAmt = 0;
                decimal decTotalAmnt = 0;
                decimal decdgvtxtgrossValue = 0, decDiscountCalc = 0, decNetAmount = 0;
                decimal decTaxPercent = 0;
                decimal decTaxId = 0;
                DataGridViewRow dgrow = dgvPurchaseReturn.Rows[inIndexOfRow];
                ProductInfo infoProduct = new ProductInfo();
                ProductSP spProduct = new ProductSP();
                TaxInfo infotax = new TaxInfo();
                TaxSP spTax = new TaxSP();

                if (dgrow.Cells["dgvtxtqty"].Value != null && dgrow.Cells["dgvtxtqty"].Value.ToString() != string.Empty)
                {
                    decQty = Convert.ToDecimal(dgrow.Cells["dgvtxtqty"].Value.ToString());
                }

                if (dgrow.Cells["dgvtxtrate"].Value != null && dgrow.Cells["dgvtxtrate"].Value.ToString() != string.Empty)
                {
                    decRate = Convert.ToDecimal(dgrow.Cells["dgvtxtrate"].Value.ToString());
                    decdgvtxtgrossValue = decQty * decRate;
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgrow.Cells["dgvtxtgrossValue"].Value != null && dgrow.Cells["dgvtxtgrossValue"].Value.ToString() != string.Empty)
                {
                    dgrow.Cells["dgvtxtgrossValue"].Value = Math.Round(decdgvtxtgrossValue, PublicVariables._inNoOfDecimalPlaces);
                    if (dgrow.Cells["dgvtxtdiscount"].Value != null && dgrow.Cells["dgvtxtdiscount"].Value.ToString() != string.Empty)
                    {
                        decDiscountCalc = Convert.ToDecimal(dgrow.Cells["dgvtxtdiscount"].Value.ToString());
                        if (decdgvtxtgrossValue >= decDiscountCalc)
                        {
                            decNetAmount = Math.Round((decdgvtxtgrossValue - decDiscountCalc), PublicVariables._inNoOfDecimalPlaces);
                            dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                        else
                        {
                            dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        }
                    }
                    else
                    {
                        dgrow.Cells["dgvtxtdiscount"].Value = 0;
                        dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                    }
                }
                if (dgrow.Cells["dgvtxtNetAmount"].Value != null && dgrow.Cells["dgvtxtNetAmount"].Value.ToString() != string.Empty)
                {
                    decNetAmount = Math.Round(decdgvtxtgrossValue - decDiscountCalc, PublicVariables._inNoOfDecimalPlaces);
                    decNetAmount = Convert.ToDecimal(dgrow.Cells["dgvtxtNetAmount"].Value.ToString());
                    dgrow.Cells["dgvtxtNetAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                }
                if (dgvcmbTax.Visible)
                {
                    if (dgrow.Cells["dgvtxtproductId"].Value != null && dgrow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty)
                    {
                        if (dgrow.Cells["dgvcmbTax"].Value != null && dgrow.Cells["dgvcmbTax"].Value.ToString() != string.Empty && dgrow.Cells["dgvcmbTax"].Value.ToString() != "NA")
                        {
                            decTaxId = Convert.ToDecimal(dgrow.Cells["dgvcmbTax"].Value.ToString());
                            infotax = spTax.TaxView(decTaxId);
                            decTaxPercent = infotax.Rate;
                            if (decTaxPercent != 0)
                            {
                                if (strTaxComboFill != string.Empty)
                                {
                                    decTaxAmt = ((decNetAmount * decTaxPercent) / 100);
                                }
                                else
                                {
                                    dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                }
                                decTotalAmnt = Math.Round((decNetAmount + decTaxAmt), PublicVariables._inNoOfDecimalPlaces);
                                dgrow.Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmt, PublicVariables._inNoOfDecimalPlaces);
                                decTaxAmt = Convert.ToDecimal(dgrow.Cells["dgvtxttaxAmount"].Value.ToString());
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decTotalAmnt, PublicVariables._inNoOfDecimalPlaces);
                            }
                            else
                            {
                                dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                                dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                            }
                        }
                        else
                        {
                            decTaxPercent = 0;
                            dgrow.Cells["dgvtxttaxAmount"].Value = "0";
                            dgrow.Cells["dgvtxtAmount"].Value = Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces);
                        }
                    }
                    Calculate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:34 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #10
0
 /// <summary>
 /// Function for Return from productCreationPopup
 /// </summary>
 /// <param name="decProductId"></param>
 public void ReturnFromProductCreation(decimal decProductId)
 {
     frmProductCreation productcreation = new frmProductCreation();
     ProductInfo infoProduct = new ProductInfo();
     ProductSP spProduct = new ProductSP();
     try
     {
         int inI = dgvPurchaseReturn.CurrentRow.Index;
         this.Enabled = true;
         base.Show();
         if (decProductId != 0)
         {
             infoProduct = spProduct.ProductView(decProductId);
             strProductCode = infoProduct.ProductCode;
             productDetailsFillFromProductCreation(productcreation, decProductId, inI);
         }
         dgvPurchaseReturn.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:25" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #11
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);
     }
 }
예제 #12
0
 /// <summary>
 /// Function to fill the dataGridView from productSearchPopup when Cntrl+F navigation key used
 /// </summary>
 /// <param name="frmProductSearchPopup"></param>
 /// <param name="decproductId"></param>
 /// <param name="decCurrentRowIndex"></param>
 public void CallFromProductSearchPopup(frmProductSearchPopup frmProductSearchPopup, decimal decproductId, decimal decCurrentRowIndex)
 {
     try
     {
         ProductInfo infoProduct = new ProductInfo();
         ProductSP spProduct = new ProductSP();
         base.Show();
         this.frmProductSearchPopupObj = frmProductSearchPopup;
         UnitConvertionSP SPUnitConversion = new UnitConvertionSP();
         infoProduct = spProduct.ProductView(decproductId);
         int inRowcount = dgvPurchaseReturn.Rows.Count;
         if (decCurrentRowIndex == inRowcount - 1)
         {
             dgvPurchaseReturn.Rows.Add();
         }
         for (int i = 0; i < inRowcount; i++)
         {
             if (i == decCurrentRowIndex)
             {
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductCode"].Value = infoProduct.ProductCode;
                 FillProductDetails(infoProduct.ProductCode.ToString(), i);
             }
         }
         frmProductSearchPopupObj.Close();
         frmProductSearchPopupObj = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #13
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);
     }
 }
예제 #14
0
 /// <summary>
 /// To Get Default Product Values
 /// </summary>
 /// <param name="inindex"></param>
 /// <param name="decproductId"></param>
 public void ProductDefaultValues(int inindex, decimal decproductId)
 {
     try
     {
         UnitSP spUnit = new UnitSP();
         isValueChange = false;
         infoProduct = spProduct.ProductView(decproductId);
         dgvProduct.Rows[inindex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
         dgvProduct.Rows[inindex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
         TransactionsGeneralFill obj = new TransactionsGeneralFill();
         DataTable dtblUnitViewall = new DataTable();
         dtblUnitViewall = obj.UnitViewAllByProductId(dgvProduct, decproductId.ToString(), inindex);
         BatchSP spBatch = new BatchSP();
         spBatch.BatchViewbyProductIdForComboFillInGrid(decproductId, dgvProduct, inindex);
         isValueChange = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("RO40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #15
0
        public void SaveFunction()
        {
            try
            {

                ProductSP spProduct = new ProductSP();
                SettingsSP Spsetting = new SettingsSP();
                infoRejectionOutMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoRejectionOutMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());

                if (isAutomatic == true)
                {
                    infoRejectionOutMaster.SuffixPrefixId = decRejectionOutSuffixPrefixId;
                    infoRejectionOutMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoRejectionOutMaster.SuffixPrefixId = 0;
                    infoRejectionOutMaster.VoucherNo = txtRejectionOutNo.Text.Trim();
                }

                if (cmbMaterialReceiptNo.SelectedValue != null)
                {
                    infoRejectionOutMaster.MaterialReceiptMasterId = Convert.ToDecimal(Convert.ToString(cmbMaterialReceiptNo.SelectedValue));
                }
                else
                {
                    infoRejectionOutMaster.MaterialReceiptMasterId = 0;
                }

                if (cmbCurrency.SelectedValue != null)
                {
                    infoRejectionOutMaster.ExchangeRateId = Convert.ToDecimal(Convert.ToString(cmbCurrency.SelectedValue));
                }
                infoRejectionOutMaster.VoucherTypeId = decRejectionOutVoucherTypeId;

                infoRejectionOutMaster.InvoiceNo = txtRejectionOutNo.Text.Trim();
                infoRejectionOutMaster.UserId = PublicVariables._decCurrentUserId;
                infoRejectionOutMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoRejectionOutMaster.Narration = txtNarration.Text.Trim();
                infoRejectionOutMaster.LrNo = txtLrNo.Text.Trim();
                infoRejectionOutMaster.TransportationCompany = txtTransportationCompany.Text.Trim();
                infoRejectionOutMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
                infoRejectionOutMaster.Extra1 = string.Empty;
                infoRejectionOutMaster.Extra2 = string.Empty;
                if (decRejectionOutId == 0)
                {
                    decRejectionOutMasterIdentity = spRejectionOutMaster.RejectionOutMasterAddWithReturnIdentity(infoRejectionOutMaster);
                }
                else
                {
                    infoRejectionOutMaster.RejectionOutMasterId = decRejectionOutId;
                    spRejectionOutMaster.RejectionOutMasterEdit(infoRejectionOutMaster);
                }
                if (decRejectionOutId == 0)
                {
                    infoRejectionOutDetails.RejectionOutMasterId = decRejectionOutMasterIdentity;
                }
                else
                {
                    spRejectionOutDetails.RejectionOutDetailsDeleteByRejectionOutMasterId(decRejectionOutId);
                    spStockPosting.DeleteStockPostingByAgnstVouTypeIdAndAgnstVouNo(decRejectionOutVoucherTypeId, strRejectionOutVoucherNo);
                    infoRejectionOutDetails.RejectionOutMasterId = decRejectionOutId;
                }
                int inRowcount = dgvProduct.Rows.Count;
                for (int inI = 0; inI <= inRowcount - 1; inI++)
                {

                    if (dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvtxtmaterialReceiptDetailsId"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.MaterialReceiptDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString());
                    }
                    else
                    {
                        infoRejectionOutDetails.MaterialReceiptDetailsId = 0;
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty)
                    {
                        infoProduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                        infoRejectionOutDetails.ProductId = infoProduct.ProductId;
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                        infoRejectionOutDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtunitConversionId"].Value.ToString());
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value);
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value);
                    }
                    if (dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString() != string.Empty)
                    {
                        infoRejectionOutDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value);
                    }
                    infoRejectionOutDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                    infoRejectionOutDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                    infoRejectionOutDetails.Extra1 = string.Empty;
                    infoRejectionOutDetails.Extra2 = string.Empty;
                    decRejectionOutDetailsIdentity = spRejectionOutDetails.RejectionOutDetailsAddWithReturnIdentity(infoRejectionOutDetails);
                    AddStockPosting();
                }

                if (decRejectionOutId == 0)
                {
                    Messages.SavedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (Spsetting.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decRejectionOutMasterIdentity);
                        }
                        else
                        {
                            Print(decRejectionOutMasterIdentity);
                        }
                    }
                    clear();
                }
                else
                {
                    Messages.UpdatedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (Spsetting.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decRejectionOutId);
                        }
                        else
                        {
                            Print(decRejectionOutId);
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("RO33:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #16
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);
            }
        }
예제 #17
0
 /// <summary>
 /// Function for Product View By ProductId for SalesInvoice
 /// </summary>
 /// <param name="strproductCode"></param>
 /// <returns></returns>
 public ProductInfo ProductViewByProductIdforSalesInvoice(string strproductCode)
 {
     ProductInfo productinfo = new ProductInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ProductViewByProductIdforSalesInvoice", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal);
         sprmparam.Value = strproductCode;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             productinfo.ProductId = Convert.ToDecimal(sdrreader[0].ToString());
             productinfo.ProductCode = sdrreader[1].ToString();
             productinfo.ProductName = sdrreader[2].ToString();
             productinfo.GroupId = Convert.ToDecimal(sdrreader[3].ToString());
             productinfo.BrandId = Convert.ToDecimal(sdrreader[4].ToString());
             productinfo.UnitId = Convert.ToDecimal(sdrreader[5].ToString());
             productinfo.SizeId = Convert.ToDecimal(sdrreader[6].ToString());
             productinfo.ModelNoId = Convert.ToDecimal(sdrreader[7].ToString());
             productinfo.TaxId = Convert.ToDecimal(sdrreader[8].ToString());
             productinfo.TaxapplicableOn = sdrreader[9].ToString();
             productinfo.PurchaseRate = Convert.ToDecimal(sdrreader[10].ToString());
             productinfo.SalesRate = Convert.ToDecimal(sdrreader[11].ToString());
             productinfo.Mrp = Convert.ToDecimal(sdrreader[12].ToString());
             productinfo.MinimumStock = Convert.ToDecimal(sdrreader[13].ToString());
             productinfo.MaximumStock = Convert.ToDecimal(sdrreader[14].ToString());
             productinfo.ReorderLevel = Convert.ToDecimal(sdrreader[15].ToString());
             productinfo.GodownId = Convert.ToDecimal(sdrreader[16].ToString());
             productinfo.RackId = Convert.ToDecimal(sdrreader[17].ToString());
             productinfo.IsallowBatch = bool.Parse(sdrreader[18].ToString());
             productinfo.Ismultipleunit = bool.Parse(sdrreader[19].ToString());
             productinfo.IsBom = bool.Parse(sdrreader[20].ToString());
             productinfo.Isopeningstock = bool.Parse(sdrreader[21].ToString());
             productinfo.Narration = sdrreader[22].ToString();
             productinfo.IsActive = bool.Parse(sdrreader[23].ToString());
             productinfo.IsshowRemember = bool.Parse(sdrreader[24].ToString());
             productinfo.Extra1 = sdrreader[25].ToString();
             productinfo.Extra2 = sdrreader[26].ToString();
             productinfo.ExtraDate = PublicVariables._dtCurrentDate;
             productinfo.PartNo = sdrreader[28].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return productinfo;
 }
예제 #18
0
 /// <summary>
 /// Function to save the sales quatation
 /// </summary>
 public void SaveFunction()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
     SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
     SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo();
     SettingsSP spSettings = new SettingsSP();
     ProductSP spProduct = new ProductSP();
     ProductInfo infoproduct = new ProductInfo();
     try
     {
         infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text);
         infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString());
         infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         if (isAutomatic)
         {
             infoSalesQuotationMaster.SuffixPrefixId = decSalesQuotationPreffixSuffixId;
             infoSalesQuotationMaster.VoucherNo = strSalesQuotationNo;
         }
         else
         {
             infoSalesQuotationMaster.SuffixPrefixId = 0;
             infoSalesQuotationMaster.VoucherNo = SpSalesQuotationMaster.VoucherNoMax(decsalesQuotationTypeId);
         }
         infoSalesQuotationMaster.VoucherTypeId = decsalesQuotationTypeId;
         infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text;
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId;
         infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
         infoSalesQuotationMaster.Narration = txtNarration.Text.Trim();
         infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoSalesQuotationMaster.Extra1 = string.Empty;
         infoSalesQuotationMaster.Extra2 = string.Empty;
         if (cbxApproved.Checked)
         {
             infoSalesQuotationMaster.Approved = true;
         }
         else
         {
             infoSalesQuotationMaster.Approved = false;
         }
         decSalesQuotationmasterIdentity = Convert.ToDecimal(SpSalesQuotationMaster.SalesQuotationMasterAdd(infoSalesQuotationMaster));
         int inRowcount = dgvProduct.Rows.Count;
         for (int inI = 0; inI < inRowcount - 1; inI++)
         {
             infoSalesQuotationDetails.QuotationMasterId = decSalesQuotationmasterIdentity;
             if (dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty)
             {
                 infoproduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesQuotationDetails.ProductId = infoproduct.ProductId;
             }
             if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId);
                 infoSalesQuotationDetails.UnitConversionId = unitConversion;
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value);
             }
             else
             {
                 infoSalesQuotationDetails.BatchId = 0;
             }
             infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
             infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
             infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
             infoSalesQuotationDetails.Extra1 = string.Empty;
             infoSalesQuotationDetails.Extra2 = string.Empty;
             SpSalesQuotationDetails.SalesQuotationDetailsAdd(infoSalesQuotationDetails);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (dgvProduct.Rows.Count > 0)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decSalesQuotationmasterIdentity);
                 }
                 else
                 {
                     Print(decSalesQuotationmasterIdentity);
                 }
             }
             else
             {
                 Messages.InformationMessage("No data found");
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:32" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #19
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);
     }
 }
예제 #20
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);
            }
        }
예제 #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);
            }

        }
예제 #22
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);
            }
        }
예제 #23
0
 /// <summary>
 ///  Grid fill function Againest DeliveryNote
 /// </summary>
 public void gridFillAgainestDeliveryNote()
 {
     DeliveryNoteMasterSP SPDeliveryNoteMaster = new DeliveryNoteMasterSP();
     DeliveryNoteDetailsSP SPDeliveryNoteDetails = new DeliveryNoteDetailsSP();
     ProductInfo infoproduct = new ProductInfo();
     SalesMasterSP spSalesMaster = new SalesMasterSP();
     BrandInfo InfoBrand = new BrandInfo();
     TaxInfo infoTax = new TaxInfo();
     TaxSP SPTax = new TaxSP();
     try
     {
         if (cmbSalesModeOrderNo.SelectedIndex > 0)
         {
             inMaxCount = 0;
             isValueChange = false;
             for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++)
             {
                 if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty)
                 {
                     lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString());
                 }
             }
             dgvSalesInvoice.Rows.Clear();
             isValueChange = true;
             DataTable dtblMaster = SPDeliveryNoteMaster.SalesInvoiceGridfillAgainestDeliveryNote(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()));
             cmbPricingLevel.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["pricingLevelId"].ToString());
             cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString());
             cmbPricingLevel.Enabled = false;
             cmbCurrency.Enabled = false;
             DataTable dtblDetails = SPDeliveryNoteDetails.SalesInvoiceGridfillAgainestDeliveryNoteUsingDeliveryNoteDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), decSalesInvoiceIdToEdit, DecSalesInvoiceVoucherTypeId);
             dtblDeliveryNoteDetails = dtblDetails;
             int inRowIndex = 0;
             foreach (DataRow drowDetails in dtblDetails.Rows)
             {
                 dgvSalesInvoice.Rows.Add();
                 IsSetGridValueChange = false;
                 isValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0";
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                 infoproduct = spSalesMaster.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate;
                 InfoBrand = new BrandSP().BrandView(infoproduct.BrandId);
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName;
                 infoTax = SPTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId;
                 isValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString();
                 isFromAgainest = true;
                 gridColumnMakeEnables();
                 int intIndex = 0;
                 intIndex = Convert.ToInt32(drowDetails["deliveryNoteDetailsId"].ToString());
                 if (inMaxCount < intIndex)
                     inMaxCount = intIndex;
                 inRowIndex++;
                 isValueChange = true;
                 isFromAgainest = false;
                 GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2);
                 discountCalculation(dgvSalesInvoice.Rows.Count - 2);
                 taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2);
             }
             IsSetGridValueChange = true;
             for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i)
                 dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString();
             SerialNoforSalesInvoice();
             strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString();
             strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString();
             decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value);
         }
         else
         {
             SiGridTotalAmountCalculation();
             ClearGridAgainest();
         }
         SiGridTotalAmountCalculation();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 53" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #24
0
        private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            try
            {

                if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString()) != 0)
                    {
                        if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
                        {
                            SalesQuotationDetailsSP spSalesQuationDetails = new SalesQuotationDetailsSP();
                            decimal decReferencedQty = Math.Round(spSalesQuationDetails.SalesQuatationReferenceCheck(Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString())),PublicVariables._inNoOfDecimalPlaces);
                            decimal decQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString());
                            if (decQty < decReferencedQty)
                            {
                                Messages.InformationMessage("Quantity in row " + (e.RowIndex + 1) + " should be greater than " + decReferencedQty);
                                IsCellValue = false;
                                dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Math.Round(decReferencedQty,PublicVariables._inNoOfDecimalPlaces);
                                IsCellValue = true;
                            }
                        }
                    }
                    AmountCalculation("dgvtxtQty", e.RowIndex);
                    TotalAmountCalculation();
                }
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
                    {
                        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, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces));
                                    }
                                }
                            }
                            AmountCalculation("dgvtxtQty", e.RowIndex);
                            TotalAmountCalculation();
                        }
                    }
                }
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbBatch")
                {
                    if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                    {
                        string strProductCode = string.Empty;
                        ProductInfo infoproduct = new ProductInfo();
                        ProductSP SpProduct = new ProductSP();
                        decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value);
                        dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = SpProduct.BarcodeViewByBatchId(decBatchId);
                        strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString();
                        infoproduct = SpProduct.ProductViewByCode(strProductCode);
                        DateTime dtcurrentDate = PublicVariables._dtCurrentDate;
                        decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces;
                        decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(infoproduct.ProductId, dtcurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), decNodecplaces);
                        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);
                            }
                            AmountCalculation("dgvtxtQty", e.RowIndex);
                            TotalAmountCalculation();
                        }
                    }
                }
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtExchangeRate" && isAmountcalc)
                {
                    AmountCalculation("dgvtxtExchangeRate", e.RowIndex);
                    TotalAmountCalculation();
                }
                //---------------while changing Rate,corresponding change in amount----
                else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc)
                {
                    AmountCalculation("dgvtxtRate", e.RowIndex);
                    TotalAmountCalculation();
                }
                //----while changing amount ,corresponding chnage in total amount-------
                
                CheckInvalidEntriesInDataGridProduct(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:76" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #25
0
 /// <summary>
 /// Function to fill Sales invoice grid while return from Product creation when creating Product 
 /// </summary>
 /// <param name="decProductId"></param>
 public void ReturnFromProductCreation(decimal decProductId)
 {
     ProductInfo infoProduct = new ProductInfo();
     ProductSP spProduct = new ProductSP();
     try
     {
         this.Enabled = true;
         this.Activate();
         if (decProductId != 0)
         {
             infoProduct = spProduct.ProductView(decProductId);
             strProductCode = infoProduct.ProductCode;
             ProductDetailsFill(strProductCode, dgvSalesInvoice.CurrentRow.Index, "ProductCode");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 88" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #26
0
 /// <summary>
 /// Function to fill the grid to edit the details
 /// </summary>
 public void SalesQuotationDetailsEditFill()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo();
     ProductSP SpProduct = new ProductSP();
     ProductInfo infoproduct = new ProductInfo();
     try
     {
         for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++)
         {
             infoSalesQuotationDetails.QuotationMasterId = decSalesquotationMasterId;
             infoSalesQuotationDetails.QuotationDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQuotationDetailsId"].Value);
             infoproduct = SpProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
             infoSalesQuotationDetails.ProductId = infoproduct.ProductId;
             infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
             if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQuotationDetailsId"].Value) == 0)
             {
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
             }
             else
             {
                 DGVUnitComboFill();
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal((dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()));
             }
             decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId);
             infoSalesQuotationDetails.UnitConversionId = unitConversion;
             infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value);
             infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value);
             infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value);
             infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value);
             infoSalesQuotationDetails.Extra1 = string.Empty;
             infoSalesQuotationDetails.Extra2 = string.Empty;
             SpSalesQuotationDetails.SalesQuotationDetailsEdit(infoSalesQuotationDetails);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #27
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);
            }
        }
예제 #28
0
        /// <summary>
        /// Function to save data to product table
        /// </summary>
        public void ProductTableFill()
        {

            try
            {
                ProductSP spProduct = new ProductSP();
                ProductInfo infoProduct = new ProductInfo();
                UnitConvertionSP spUnitConvertion = new UnitConvertionSP();
                UnitConvertionInfo infoUnitConvertion = new UnitConvertionInfo();
                infoProduct.ProductName = txtName.Text.Trim();
                infoProduct.ProductCode = txtProductCode.Text.Trim();
                if (txtPurchaseRate.Text != string.Empty)
                {
                    infoProduct.PurchaseRate = Convert.ToDecimal(txtPurchaseRate.Text.Trim());
                }
                else
                {
                    infoProduct.PurchaseRate = 0;
                }
                if (txtSalesRate.Text != string.Empty)
                {
                    infoProduct.SalesRate = Convert.ToDecimal(txtSalesRate.Text.Trim());
                }
                else
                {
                    infoProduct.SalesRate = 0;
                }
                if (txtMrp.Text != string.Empty)
                {
                    infoProduct.Mrp = Convert.ToDecimal(txtMrp.Text.Trim());
                }
                else
                {
                    infoProduct.Mrp = 0;
                }
                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;

                infoUnitConvertion.UnitId = Convert.ToDecimal(cmbUnit.SelectedValue);
                infoUnitConvertion.ConversionRate = 1;
                infoUnitConvertion.Quantities = string.Empty;
                infoUnitConvertion.Extra1 = string.Empty;

                infoUnitConvertion.Extra2 = string.Empty;
                infoUnitConvertion.ExtraDate = DateTime.Now;

                if (cmbTax.SelectedIndex == 0)
                {
                    infoProduct.TaxapplicableOn = "Rate";
                }
                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;
                }
                else
                {
                    infoProduct.IsallowBatch = true;
                }
                if (cmbBom.SelectedIndex == 0)
                {
                    infoProduct.IsBom = false;
                }
                else
                {
                    if (isSaveBomCheck)
                    {
                        infoProduct.IsBom = true;
                    }
                    else
                    {
                        infoProduct.IsBom = false;
                    }

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

                }
                else
                {
                    infoProduct.Isopeningstock = true;
                    infoProduct.PurchaseRate = Convert.ToDecimal(dgvProductCreation.Rows[0].Cells["dgvtxtrate"].Value);
                }
                if (cmbMultipleUnit.SelectedIndex == 0)
                {

                    infoProduct.Ismultipleunit = false;
                }
                else
                {
                    if (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;
                }

                decSaveProduct = spProduct.ProductAdd(infoProduct);
                infoUnitConvertion.ProductId = decSaveProduct;
                spUnitConvertion.UnitConvertionAdd(infoUnitConvertion);

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


        }
예제 #29
0
 /// <summary>
 /// Function to fill productdetails for consumption
 /// </summary>
 public void ProductDetailsFillConsumption(string strProduct, int inRowIndex, string strFillMode)
 {
     decimal decProductId = 0;
     decimal decGodownId = 0;
     try
     {
         StockJournalDetailsSP spStockJournalDetails = new StockJournalDetailsSP();
         ProductInfo infoProductFill = new ProductInfo();
         DataTable dtbl = new DataTable();
         BatchComboFill();
         RackComboFill();
         GodownComboFill();
         UnitComboFill();
         if (strFillMode == "ProductCode")
         {
             dtbl = spStockJournalDetails.StockJournalDetailsByProductCode(decVoucherTypeId, strProduct);
         }
         else if (strFillMode == "ProductName")
         {
             dtbl = spStockJournalDetails.StockJournalDetailsByProductName(decVoucherTypeId, strProduct);
         }
         else if (strFillMode == "Barcode")
         {
             dtbl = spStockJournalDetails.StockJournalDetailsViewByBarcode(decVoucherTypeId, strProduct);
         }
         if (dtbl.Rows.Count != 0)
         {
             decProductId = Convert.ToDecimal(dtbl.Rows[0]["productId"]);
             decGodownId = Convert.ToDecimal(dtbl.Rows[0]["godownId"]);
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductId"].Value = dtbl.Rows[0]["productId"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionBarcode"].Value = dtbl.Rows[0]["barcode"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductCode"].Value = dtbl.Rows[0]["productCode"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductName"].Value = dtbl.Rows[0]["productName"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionunitConversionId"].Value = dtbl.Rows[0]["unitConversionId"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionunitId"].Value = Convert.ToDecimal(dtbl.Rows[0]["unitId"].ToString());
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionRate"].Value = dtbl.Rows[0]["salesRate"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionGodown"].Value = dtbl.Rows[0]["godownId"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionRack"].Value = dtbl.Rows[0]["rackId"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionConversionRate"].Value = dtbl.Rows[0]["conversionRate"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionBatch"].Value = dtbl.Rows[0]["batchId"];
             dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionQty"].Value = string.Empty;
             if (strFillMode == "Barcode")
             {
                 dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionBatch"].Value = dtbl.Rows[0]["batchId"];
             }
             dgvConsumption.Rows[inRowIndex].HeaderCell.Value = "X";
             dgvConsumption.Rows[inRowIndex].HeaderCell.Style.ForeColor = Color.Red;
         }
         else
         {
             if (dgvConsumption.CurrentRow.Index < dgvConsumption.RowCount - 1)
             {
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionBarcode"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductCode"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductId"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionProductName"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionQty"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionunitId"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionConversionRate"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionunitConversionId"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionGodown"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionRack"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvcmbConsumptionBatch"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionRate"].Value = string.Empty;
                 dgvConsumption.Rows[inRowIndex].Cells["dgvtxtConsumptionAmount"].Value = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SJ:17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #30
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);
            }

        }