Exemplo n.º 1
0
 /// <summary>
 /// grid fill function 
 /// </summary>
 public void GridFill()
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         ListObj = bllUnit.UnitSearch(txtUnitSearch.Text.Trim());
         dgvUnitSearch.DataSource = ListObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("U1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// here checking the unit name if already exists for create new unit
 /// </summary>
 /// <returns></returns>
 public bool CheckExistenceOfUnitName()
 {
     bool isExist = false;
     try
     {
         UnitBll bllUnit = new UnitBll();
         isExist = bllUnit.UnitCheckExistence(txtUnitname.Text.Trim(), 0);
         if (isExist)
         {
             string strUnitNames = txtUnitname.Text.Trim();
             if (strUnitNames.ToLower() == strUnitName.ToLower())
             {
                 isExist = false;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("U2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isExist;
 }
 /// <summary>
 /// Work on cmbUnit Cell Leave
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbUnit_Leave(object sender, EventArgs e)
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         decId = Convert.ToDecimal(cmbUnit.SelectedValue);
         strUnitNameForGrid = bllUnit.UnitName(decId);
         isSaveMulUnitCheck = false;
         if (dtblMulUnit != null)
         {
             dtblMulUnit.Clear();
         }
         if (dtblForUnitIdInOpeNingStock != null)
         {
             dtblForUnitIdInOpeNingStock.Clear();
         }
         if (dtblFromMulUnitForUpdate != null)
         {
             dtblFromMulUnitForUpdate.Clear();
         }
         if (btnSave.Text == "Update")
         {
             cmbMultipleUnit.SelectedIndex = 0;
             isMulUnitFromRgister = false;
             isCheck = true;
         }
         if (dgvProductCreation.Rows.Count != 0)
         {
             for (int inI = 0; inI <= dgvProductCreation.Rows.Count - 1; inI++)
             {
                 dgvProductCreation.Rows[inI].Cells["dgvtxtunit"].Value = strUnitNameForGrid;
                 DefaultUnitFillingInProductGrid();
             }
         }
         else
         {
             dgvProductCreation.Rows[0].Cells["dgvtxtunit"].Value = strUnitNameForGrid;
             DefaultUnitFillingInProductGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:106" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to save an item into table
        /// </summary>
        public void Save()
        {
            ExchangeRateBll BllExchangeRate = new ExchangeRateBll();

            SalesReturnBll bllSalesReturn = new SalesReturnBll();

            StockPostingBll BllStockPosting = new StockPostingBll();
            StockPostingBll BllStockPostingf = new StockPostingBll();
            LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
            PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
            UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
            UnitBll bllUnit = new UnitBll();
            try
            {
                if (txtReturnNo.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Enter return no", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtReturnNo.Focus();
                }
                else if (bllSalesReturn.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Save")
                {
                    Messages.InformationMessage("Return  number already exist");
                    txtReturnNo.Focus();
                }
                else if (txtDate.Text == "")
                {
                    MessageBox.Show("Select a date in between financial year", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDate.Focus();
                }
                else if (cmbCashOrParty.SelectedValue == null)
                {
                    MessageBox.Show("Select cash/party", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmbCashOrParty.Focus();
                }
                else if (cmbSalesAccount.SelectedValue == null)
                {
                    MessageBox.Show("Select sales account", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmbSalesAccount.Focus();
                }
                else if (cmbCurrency.SelectedValue == null)
                {
                    MessageBox.Show("Select currency", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmbCurrency.Focus();
                }
                else
                {
                    if (isAutomatic)
                    {
                        if (strVoucherNo != string.Empty)
                        {
                            infoSalesReturnMaster.VoucherNo = strVoucherNo;
                        }
                        if (txtReturnNo.Text != string.Empty)
                        {
                            infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text;
                        }
                    }
                    else
                    {
                        infoSalesReturnMaster.VoucherNo = txtReturnNo.Text;
                        infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text;
                    }
                    if (decSalesReturnVoucherTypeId != 0)
                    {
                        infoSalesReturnMaster.VoucherTypeId = decSalesReturnVoucherTypeId;
                    }
                    if (decSalesReturnSuffixPrefixId != 0)
                    {
                        infoSalesReturnMaster.SuffixPrefixId = decSalesReturnSuffixPrefixId;
                    }
                    if (cmbCashOrParty.SelectedValue != null)
                    {
                        infoSalesReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                    }
                    if (cmbInvoiceNo.SelectedValue != null)
                    {
                        infoSalesReturnMaster.SalesMasterId = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString());
                    }
                    else
                    {
                        infoSalesReturnMaster.SalesMasterId = 0;
                    }
                    if (cmbSalesAccount.SelectedValue != null)
                    {
                        infoSalesReturnMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString());
                    }
                    if (cmbPricingLevel.SelectedValue != null)
                    {
                        infoSalesReturnMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
                    }
                    else
                    {
                        infoSalesReturnMaster.PricinglevelId = 0;
                    }
                    if (cmbSalesMan.SelectedValue != null)
                    {
                        infoSalesReturnMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
                    }
                    else
                    {
                        infoSalesReturnMaster.EmployeeId = 0;
                    }
                    if (cmbCurrency.SelectedValue != null)
                    {
                        infoSalesReturnMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                        decExchangeRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(infoSalesReturnMaster.ExchangeRateId);
                    }
                    infoSalesReturnMaster.Narration = txtNarration.Text.Trim();
                    infoSalesReturnMaster.UserId = PublicVariables._decCurrentUserId;
                    infoSalesReturnMaster.LrNo = txtLRNo.Text.Trim();
                    infoSalesReturnMaster.TransportationCompany = txtTransportationComp.Text.Trim();
                    infoSalesReturnMaster.Date = Convert.ToDateTime(txtDate.Text);
                    if (txtTotalAmount.Text != string.Empty)
                    {
                        infoSalesReturnMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
                    }
                    if (txtGrandTotal.Text != string.Empty)
                    {
                        infoSalesReturnMaster.grandTotal = Convert.ToDecimal(txtGrandTotal.Text);
                    }
                    if (lblTaxAmount.Text != string.Empty)
                    {
                        infoSalesReturnMaster.TaxAmount = Convert.ToDecimal(lblTaxAmount.Text);
                    }
                    infoSalesReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoSalesReturnMaster.Extra1 = string.Empty;
                    infoSalesReturnMaster.Extra2 = string.Empty;
                    if (txtBillDiscount.Text != string.Empty)
                    {
                        infoSalesReturnMaster.Discount = Convert.ToDecimal(txtBillDiscount.Text);
                    }
                    else
                    {
                        infoSalesReturnMaster.Discount = 0;
                    }
                    decimal decNetTotal = 0;
                    decimal decGrandTotal = 0;
                    string strQuantities = string.Empty;
                    if (btnSave.Text == "Update")
                    {
                        infoSalesReturnMaster.SalesReturnMasterId = decSalesReturnMasterId;
                        bllSalesReturn.SalesReturnMasterEdit(infoSalesReturnMaster);
                        BllLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text);
                        BllLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text);
                        BllStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decSalesReturnVoucherTypeId);
                        bllSalesReturnBill.SalesReturnBillTaxDeleteBySalesReturnMasterId(decSalesReturnMasterId);
                    }
                    else
                    {
                        decSalesReturnMasterId = bllSalesReturn.SalesReturnMasterAdd(infoSalesReturnMaster);
                    }
                    SalesReturnDetailsInfo infoSalesReturnDetailsInfo = new SalesReturnDetailsInfo();
                    infoSalesReturnDetailsInfo.Extra1 = string.Empty;
                    infoSalesReturnDetailsInfo.Extra2 = string.Empty;
                    if (btnSave.Text == "Update")
                    {
                        foreach (var strId in lstArrOfRemove)
                        {
                            decimal decDeleteId = Convert.ToDecimal(strId);
                            bllSalesReturn.SalesReturnDetailsDelete(decDeleteId);
                        }
                    }
                    foreach (DataGridViewRow DGVSalesReturn in dgvSalesReturn.Rows)
                    {
                        if (DGVSalesReturn.Cells["productId"].Value != null && DGVSalesReturn.Cells["productId"].Value.ToString() != string.Empty)
                        {
                            infoSalesReturnDetailsInfo.SalesReturnMasterId = decSalesReturnMasterId;
                            infoSalesReturnDetailsInfo.ProductId = Convert.ToDecimal(DGVSalesReturn.Cells["productId"].Value.ToString());
                            if (DGVSalesReturn.Cells["dgvTextQty"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.Qty = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextQty"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvTextRate"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.Rate = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextRate"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvCmbUnit"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.UnitId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbUnit"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["unitConversionId"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.UnitConversionId = Convert.ToDecimal(DGVSalesReturn.Cells["unitConversionId"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.Discount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvCmbTax"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.TaxId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbTax"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.TaxId = 0;
                            }
                            if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.BatchId = 0;
                            }
                            if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.BatchId = 0;
                            }
                            if (DGVSalesReturn.Cells["dgvCmbGodown"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.GodownId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbGodown"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.GodownId = 0;
                            }
                            if (DGVSalesReturn.Cells["dgvCmbRack"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.RackId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbRack"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.RackId = 0;
                            }
                            if (DGVSalesReturn.Cells["dgvTextTaxAmount"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.TaxAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextTaxAmount"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvTextGrossValue"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.GrossAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextGrossValue"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvTextNetValue"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.NetAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextNetValue"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvTextAmount1"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.Amount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextAmount1"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["dgvSNo"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.SlNo = Convert.ToInt32(DGVSalesReturn.Cells["dgvSNo"].Value.ToString());
                            }
                            if (DGVSalesReturn.Cells["salesDetailsId"].Value != null && cmbInvoiceNo.SelectedValue != null)
                            {
                                infoSalesReturnDetailsInfo.SalesDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesDetailsId"].Value.ToString());
                            }
                            else
                            {
                                infoSalesReturnDetailsInfo.SalesDetailsId = 0;
                            }
                            if (DGVSalesReturn.Cells["salesReturnDetailsId"].Value != null)
                            {
                                infoSalesReturnDetailsInfo.SalesReturnDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesReturnDetailsId"].Value.ToString());
                                bllSalesReturn.SalesReturnDetailsEdit(infoSalesReturnDetailsInfo);
                            }
                            else
                            {
                                decSalesReturnDetailId = bllSalesReturn.SalesReturnDetailsAdd(infoSalesReturnDetailsInfo);
                            }
                            StockPostingInfo infoStockPosting = new StockPostingInfo();
                            infoStockPosting.Date = infoSalesReturnMaster.Date;
                            if (DGVSalesReturn.Cells["voucherTypeId"].Value != null)
                            {
                                infoStockPosting.VoucherTypeId = Convert.ToDecimal(DGVSalesReturn.Cells["voucherTypeId"].Value.ToString());
                                decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId;
                                infoStockPosting.AgainstVoucherTypeId = decSalesReturnVoucherTypeId;
                            }
                            else
                            {
                                infoStockPosting.VoucherTypeId = decSalesReturnVoucherTypeId;
                                infoStockPosting.AgainstVoucherTypeId = 0;
                            }
                            if (DGVSalesReturn.Cells["voucherNo"].Value != null)
                            {
                                infoStockPosting.VoucherNo = DGVSalesReturn.Cells["voucherNo"].Value.ToString();
                                strAgainstVoucherNo = infoStockPosting.VoucherNo;
                                infoStockPosting.AgainstVoucherNo = strVoucherNo;
                            }
                            else
                            {
                                infoStockPosting.VoucherNo = strVoucherNo;
                                infoStockPosting.AgainstVoucherNo = "NA";
                            }
                            if (DGVSalesReturn.Cells["invoiceNo"].Value != null)
                            {
                                infoStockPosting.InvoiceNo = DGVSalesReturn.Cells["invoiceNo"].Value.ToString();
                                strAgainstInvoiceNo = infoStockPosting.InvoiceNo;
                                infoStockPosting.AgainstInvoiceNo = txtReturnNo.Text.Trim();
                            }
                            else
                            {
                                infoStockPosting.InvoiceNo = txtReturnNo.Text;
                                infoStockPosting.AgainstInvoiceNo = "NA";
                            }
                            infoStockPosting.ProductId = infoSalesReturnDetailsInfo.ProductId;
                            infoStockPosting.BatchId = infoSalesReturnDetailsInfo.BatchId;
                            infoStockPosting.UnitId = infoSalesReturnDetailsInfo.UnitId;
                            infoStockPosting.GodownId = infoSalesReturnDetailsInfo.GodownId;
                            infoStockPosting.RackId = infoSalesReturnDetailsInfo.RackId;
                            if (infoSalesReturnDetailsInfo.ProductId != 0 && infoSalesReturnDetailsInfo.UnitId != 0)
                            {
                                decimal decUnitConvertionRate = 0;
                                infoProduct = BllProductCreation.ProductView(infoSalesReturnDetailsInfo.ProductId);
                               List< DataTable> list = bllUnitConvertion.DGVUnitConvertionRateByUnitId(infoSalesReturnDetailsInfo.UnitId, infoProduct.ProductName);
                                foreach (DataRow drowDetails in list[0].Rows)
                                {
                                    decUnitConvertionRate = Convert.ToDecimal(drowDetails["conversionRate"].ToString());
                                }
                                strQuantities = bllUnit.UnitConversionCheck(infoSalesReturnDetailsInfo.UnitId, infoSalesReturnDetailsInfo.ProductId);
                                if (strQuantities != string.Empty)
                                {
                                    infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty / decUnitConvertionRate;
                                }
                                else
                                {
                                    infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty;
                                }
                            }
                            infoStockPosting.OutwardQty = 0;
                            infoStockPosting.Rate = infoSalesReturnDetailsInfo.Rate;
                            infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                            infoStockPosting.Extra1 = string.Empty;
                            infoStockPosting.Extra2 = string.Empty;
                           BllStockPosting.StockPostingAdd(infoStockPosting);
                        }
                    }
                    decGrandTotal = Convert.ToDecimal(txtGrandTotal.Text);
                    decNetTotal = TotalNetAmountForLedgerPosting();
                    LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                    infoLedgerPosting.Date = infoSalesReturnMaster.Date;
                    infoLedgerPosting.ChequeDate = infoSalesReturnMaster.Date;
                    infoLedgerPosting.ChequeNo = String.Empty;
                    infoLedgerPosting.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId;
                    infoLedgerPosting.VoucherNo = infoSalesReturnMaster.VoucherNo;
                    infoLedgerPosting.LedgerId = infoSalesReturnMaster.LedgerId;
                    infoLedgerPosting.Debit = 0;
                    infoLedgerPosting.Credit = (decGrandTotal * decExchangeRate);
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.InvoiceNo = infoSalesReturnMaster.InvoiceNo;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    infoLedgerPosting.LedgerId = infoSalesReturnMaster.SalesAccount;
                    infoLedgerPosting.Debit = (decNetTotal * decExchangeRate);
                    infoLedgerPosting.Credit = 0;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    if (Convert.ToDecimal(txtBillDiscount.Text == string.Empty ? "0" : txtBillDiscount.Text) > 0)
                    {
                        infoLedgerPosting.LedgerId = 8;
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.Credit = (Convert.ToDecimal(txtBillDiscount.Text) * decExchangeRate);
                        BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    }
                    LedegrPostingForTax();
                    PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
                    infoPartyBalance.Date = infoSalesReturnMaster.Date;
                    infoPartyBalance.LedgerId = infoSalesReturnMaster.LedgerId;
                    if (decAgainstVoucherTypeId != 0)
                    {
                        infoPartyBalance.VoucherTypeId = decAgainstVoucherTypeId;
                        infoPartyBalance.VoucherNo = strAgainstVoucherNo;
                        infoPartyBalance.InvoiceNo = strAgainstInvoiceNo;
                        infoPartyBalance.AgainstVoucherTypeId = infoSalesReturnMaster.VoucherTypeId;
                        infoPartyBalance.AgainstVoucherNo = infoSalesReturnMaster.VoucherNo;
                        infoPartyBalance.AgainstInvoiceNo = infoSalesReturnMaster.InvoiceNo;
                        infoPartyBalance.ReferenceType = "Against";
                    }
                    else
                    {
                        infoPartyBalance.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId;
                        infoPartyBalance.VoucherNo = infoSalesReturnMaster.VoucherNo;
                        infoPartyBalance.InvoiceNo = infoSalesReturnMaster.InvoiceNo;
                        infoPartyBalance.AgainstVoucherTypeId = 0;
                        infoPartyBalance.AgainstVoucherNo = "NA";
                        infoPartyBalance.AgainstInvoiceNo = "NA";
                        infoPartyBalance.ReferenceType = "New";
                    }

                    infoPartyBalance.Credit = infoSalesReturnMaster.TotalAmount;
                    infoPartyBalance.Debit = 0;
                    infoPartyBalance.CreditPeriod = 0;
                    infoPartyBalance.ExchangeRateId = infoSalesReturnMaster.ExchangeRateId;
                    infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoPartyBalance.Extra1 = string.Empty;
                    infoPartyBalance.Extra2 = string.Empty;
                    BllPartyBalance.PartyBalanceAdd(infoPartyBalance);
                    SalesReturnBillTaxInfo infoSalesReturnBillTax = new SalesReturnBillTaxInfo();
                    foreach (DataGridViewRow item in dgvSalesReturn2.Rows)
                    {
                        if (item.Cells["dgvTextTaxId"].Value != null)
                        {
                            infoSalesReturnBillTax.SalesReturnMasterId = decSalesReturnMasterId;
                            infoSalesReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvTextTaxId"].Value.ToString());
                            infoSalesReturnBillTax.TaxAmount = Convert.ToDecimal(item.Cells["dgvTextAmount"].Value.ToString());
                            infoSalesReturnBillTax.Extra1 = string.Empty;
                            infoSalesReturnBillTax.Extra2 = string.Empty;
                            bllSalesReturnBill.SalesReturnBillTaxAdd(infoSalesReturnBillTax);
                        }
                    }
                    if (btnSave.Text == "Save")
                    {
                        Messages.SavedMessage();
                        if (cbxPrintAfterSave.Checked == true)
                        {
                            if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decSalesReturnMasterId);
                            }
                            else
                            {
                                Print(decSalesReturnMasterId);
                            }
                        }
                        clear();
                    }
                    else
                    {
                        Messages.UpdatedMessage();
                        if (cbxPrintAfterSave.Checked == true)
                        {
                            if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decSalesReturnMasterId);
                            }
                            else
                            {
                                Print(decSalesReturnMasterId);
                            }
                        }
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SR36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// UnitComboFill
 /// </summary>
 public void UnitComboFill1(decimal decproductId, int inRow, int inColumn)
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         ListObj = bllUnit.UnitViewAllByProductId(decproductId);
         DataGridViewComboBoxCell dgvcmbUnitCell = (DataGridViewComboBoxCell)dgvProduct.Rows[inRow].Cells[inColumn];
         dgvcmbUnitCell.DataSource = ListObj[0];
         dgvcmbUnitCell.DisplayMember = "unitName";
         dgvcmbUnitCell.ValueMember = "unitId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN33:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// fill Items into the purticular controls for Update or delete
 /// </summary>
 public void FillControls()
 {
     try
     {
         StandardRateInfo infoStandardRate = new StandardRateInfo();
         standardRateBll BllStandaredRate = new standardRateBll();
         infoStandardRate = BllStandaredRate.StandardRateView(decStandardRate);
         dtpFromDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableFrom.ToString());
         dtpToDate.Value = Convert.ToDateTime(infoStandardRate.ApplicableTo.ToString());
         dtpFromDate.Text = infoStandardRate.ApplicableFrom.ToString();
         dtpToDate.Text = infoStandardRate.ApplicableTo.ToString();
         txtRate.Text = infoStandardRate.Rate.ToString();
         decProduct = infoStandardRate.ProductId;
         decUnitId = infoStandardRate.UnitId;
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         ProductInfo infoProduct = new ProductInfo();
         infoProduct = BllProductCreation.ProductViewForStandardRate(decProductId);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         decStandardRateId = infoStandardRate.StandardRateId;
         UnitInfo infoUnit = new UnitInfo();
         UnitBll bllUnit = new UnitBll();
         infoUnit = bllUnit.UnitView(decUnit);
         txtUnitName.Text = infoUnit.UnitName;
         txtProductName.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         BatchInfo infoBatch = new BatchInfo();
         BatchBll BllBatch = new BatchBll();
         decBatchId = infoStandardRate.BatchId;
         infoBatch = BllBatch.BatchView(decBatchId);
         cmbBatch.SelectedValue = infoBatch.BatchId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SRP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        ///  Function to fil Controls based on the ProductName
        /// </summary>
        /// <param name="decProductId"></param>
        public void FillControlsByProductName(decimal decProductId)
        {
            try
            {
                PriceListInfo InfoPriceList = new PriceListInfo();
                ProductInfo infoProduct = new ProductInfo();
                ProductCreationBll BllProductCreation = new ProductCreationBll();
                PriceListBll BllPriceList = new PriceListBll();
                ProductBatchInfo infoProductBatch = new ProductBatchInfo();
                infoProduct = BllProductCreation.ProductView(decProductId);
                txtProductCode.Text = infoProduct.ProductCode;
                infoProductBatch = BllProductCreation.BarcodeViewByProductCode(txtProductCode.Text);
                decProductId = infoProductBatch.ProductId;
                decBatchId = infoProductBatch.BatchId;
                InfoPriceList = BllPriceList.PriceListViewByBatchIdORProduct(decBatchId);
                batchcombofill();
                txtBarcode.Text = infoProductBatch.Barcode;
                cmbItem.Text = infoProduct.ProductName;
                cmbGodown.SelectedValue = infoProduct.GodownId;
                cmbRack.SelectedValue = infoProduct.RackId;
                UnitComboFill();
                UnitInfo infoUnit = new UnitInfo();
                infoUnit = new UnitBll().unitVieWForStandardRate(decProductId);
                cmbUnit.SelectedValue = infoUnit.UnitId;
                if (InfoPriceList.PricinglevelId != 0)
                {
                    cmbPricingLevel.SelectedValue = InfoPriceList.PricinglevelId;
                }
                else
                {
                    cmbPricingLevel.SelectedIndex = 0;
                }
                ComboTaxFill();
                cmbTax.SelectedValue = infoProduct.TaxId;
                if (txtProductCode.Text.Trim() != string.Empty && cmbItem.SelectedIndex != -1)
                {
                    decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces;
                    decimal dcRate = BllProductCreation.ProductRateForSales(decProductId, Convert.ToDateTime(txtDate.Text), decBatchId, decNodecplaces);
                    txtRate.Text = dcRate.ToString();
                    try
                    {
                        if (decimal.Parse(txtQuantity.Text) == 0)
                            txtQuantity.Text = "1";
                    }
                    catch { txtQuantity.Text = "1"; }
                    txtQuantity.Focus();

                }
                TaxAmountCalculation();
                isAfterFillControls = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("POS:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function for Unit Conversion Calculation
 /// </summary>
 /// <param name="inIndexOfRow"></param>
 public void UnitConversionCalc(int inIndexOfRow)
 {
     try
     {
         decimal decOldConversionRate = 0, decOldUnitConversionId = 0, decUnitId = 0, decProductId = 0;
         decimal decNewConversionRate = 0, decNewUnitConversionId = 0;
         decimal decProductRate = 0;
         UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
         List<DataTable> ListObj = new List<DataTable>();
         UnitBll bllUnit = new UnitBll();
         if (dgvPurchaseReturn.Rows[inIndexOfRow].Cells["dgvtxtproductId"].Value != null)
         {
             if (dgvPurchaseReturn.CurrentRow.Cells["dgvtxtproductId"].Value.ToString() != string.Empty &&
                            dgvPurchaseReturn.CurrentRow.Cells["dgvtxtproductId"].Value.ToString() != "0")
             {
                 decOldUnitConversionId = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvtxtUnitConversionId"].Value.ToString());
                 decOldConversionRate = bllUnitConvertion.UnitConversionRateByUnitConversionId(decOldUnitConversionId);
                 decUnitId = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvcmbUnit"].Value.ToString());
                 decProductId = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvtxtproductId"].Value.ToString());
                 decNewUnitConversionId = bllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(decUnitId, decProductId);
                 decNewConversionRate = bllUnitConvertion.UnitConversionRateByUnitConversionId(decNewUnitConversionId);
                 dgvPurchaseReturn.CurrentRow.Cells["dgvtxtUnitConversionId"].Value = decNewUnitConversionId;
                 if (dgvPurchaseReturn.CurrentRow.Cells["dgvtxtrate"].Value != null && dgvPurchaseReturn.CurrentRow.Cells["dgvtxtrate"].Value.ToString() != string.Empty)
                 {
                     decProductRate = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvtxtrate"].Value.ToString());
                     decProductRate = decProductRate * decOldConversionRate / decNewConversionRate;
                     dgvPurchaseReturn.CurrentRow.Cells["dgvtxtrate"].Value = Math.Round(decProductRate, PublicVariables._inNoOfDecimalPlaces);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:35" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the fields while user double click on the datagridview
 /// </summary>
 public void FillControls()
 {
     try
     {
         PriceListInfo infoPricelist = new PriceListInfo();
         PriceListBll BllPriceList = new PriceListBll();
         infoPricelist.PricelistId = decpriceListId;
         infoPricelist = BllPriceList.PriceListView(decpriceListId);
         txtRate.Text = infoPricelist.Rate.ToString();
         ProductInfo infoProduct = new ProductInfo();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         infoProduct = BllProductCreation.PriceListPopUpView(decProductId);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         BatchInfo infobatch = new BatchInfo();
        // BatchSP spBatch = new BatchSP();
         BatchBll BllBatch = new BatchBll();
         infobatch = BllBatch.BatchView(decBatchId);
         cmbBatch.SelectedValue = infobatch.BatchId;
         UnitInfo infoUnit = new UnitInfo();
         UnitBll bllUnit = new UnitBll();
         infoUnit = bllUnit.UnitView(decUnitId);
         txtUnitName.Text = infoUnit.UnitName;
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         infoPricingLevel = BllPricingLevel.PricingLevelView(decPriceLevelId);
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         txtProductName.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         txtPricingLevel.ReadOnly = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PLP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// grid cell double click event for editing purpose
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvUnitSearch_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dgvUnitSearch.CurrentRow != null)
                {
                    if (dgvUnitSearch.Rows.Count > 0 && e.ColumnIndex > -1)
                    {
                        if (dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value != null)
                        {
                            if (dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value.ToString() != string.Empty)
                            {
                                if (Convert.ToDecimal(dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value) != 1)
                                {
                                    UnitBll bllUnit = new UnitBll();
                                    UnitInfo infoUnit = new UnitInfo();
                                    decUnitid = decimal.Parse(dgvUnitSearch.CurrentRow.Cells["dgvtxtUnitId"].Value.ToString());
                                    infoUnit = bllUnit.UnitView(decUnitid);
                                    txtFormalName.Text = infoUnit.formalName;
                                    txtDecimalPlaces.Text = infoUnit.noOfDecimalplaces.ToString();
                                    txtNarration.Text = infoUnit.Narration;
                                    txtUnitSearch.Text = string.Empty;
                                    txtUnitname.Text = infoUnit.UnitName;
                                    strUnitName = infoUnit.UnitName;
                                    btnSave.Text = "Update";
                                    txtUnitname.Focus();
                                    btnDelete.Enabled = true;
                                }
                                else
                                {
                                    Messages.InformationMessage("Default unit cannot update or delete");
                                    Clear();
                                }
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("U14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// checking references fro delete
        /// </summary>
        public void DeleteFunction()
        {
            try
            {
                UnitBll bllUnit = new UnitBll();
                if (bllUnit.UnitDeleteCheck(decUnitid) <= 0)
                {
                    Messages.ReferenceExistsMessage();

                }
                else
                {
                    Clear();
                    btnSave.Text = "Save";
                    Messages.DeletedMessage();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("U7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// update function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         UnitInfo infoUnit = new UnitInfo();
         infoUnit.UnitName = txtUnitname.Text.Trim();
         infoUnit.noOfDecimalplaces = Convert.ToDecimal(txtDecimalPlaces.Text.ToString());
         infoUnit.Narration = txtNarration.Text.Trim();
         infoUnit.formalName = txtFormalName.Text.Trim();
         infoUnit.UnitId = decUnitid;
         infoUnit.Extra1 = string.Empty;
         infoUnit.Extra2 = string.Empty;
         if (CheckExistenceOfUnitName() == false)
         {
             if (bllUnit.UnitEdit(infoUnit))
             {
                 Messages.UpdatedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Already exists");
             txtUnitname.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("U4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// save function
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                UnitBll bllUnit = new UnitBll();
                UnitInfo infoUnit = new UnitInfo();
                infoUnit.UnitName = txtUnitname.Text.Trim();
                infoUnit.noOfDecimalplaces = Convert.ToDecimal(txtDecimalPlaces.Text.ToString());
                infoUnit.Narration = txtNarration.Text.Trim();
                infoUnit.formalName = txtFormalName.Text.Trim();
                infoUnit.Extra1 = string.Empty;
                infoUnit.Extra2 = string.Empty;
                infoUnit.ExtraDate = DateTime.Now;
                if (bllUnit.UnitCheckExistence(txtUnitname.Text.Trim(), 0) == false)
                {
                    decUnit = bllUnit.UnitAdd(infoUnit);
                    if (decUnit > 0)
                    {
                        Messages.SavedMessage();
                        GridFill();
                        Clear();
                    }
                }
                else
                {
                    Messages.InformationMessage(" Unit name already exist");
                    txtUnitname.Focus();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("U3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function for call from productRegister
 /// </summary>
 public void CallFromProductRegister(decimal decId, frmProductRegister frmProRegister)
 {
     try
     {
         base.Show();
         this.frmProductRegisterObj = frmProRegister;
         frmProductRegisterObj.Enabled = false;
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         ProductInfo infoProduct = new ProductInfo();
         StockPostingInfo infoStockPosting = new StockPostingInfo();
         BatchInfo infoBatch = new BatchInfo();
         StockPostingBll BllStockPosting = new StockPostingBll();
         BatchBll BllBatch = new BatchBll();
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         decProductIdForEdit = decId;
         infoProduct = BllProductCreation.ProductView(decId);
         strUnitNameForGrid = bllUnit.UnitName(infoProduct.UnitId);
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtName.Text = infoProduct.ProductName;
         txtProductCode.Text = infoProduct.ProductCode;
         cmbGroup.SelectedValue = infoProduct.GroupId;
         cmbBrand.SelectedValue = infoProduct.BrandId;
         cmbUnit.SelectedValue = infoProduct.UnitId;
         if (BllProductCreation.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 = BllBatch.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);
     }
 }
 /// <summary>
 /// Function to fill the unit combobox
 /// </summary>
 /// <param name="decId"></param>
 public void UnitComboFill(decimal decId)
 {
     try
     {
         List<DataTable> ListObj = new List<DataTable>();
         UnitBll bllUnit = new UnitBll();
         ListObj = bllUnit.UnitViewAllWithoutPerticularId(decId);
         dgvcmbmultipleunit.DataSource = ListObj[0];
         DataRow drow = ListObj[0].NewRow();
         drow["unitName"] = string.Empty;
         drow["unitId"] = 0;
         ListObj[0].Rows.InsertAt(drow, 0);
         dgvcmbmultipleunit.DisplayMember = "unitName";
         dgvcmbmultipleunit.ValueMember = "unitId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("PMU:2" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <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();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         UnitBll bllUnit = new UnitBll();
         UnitInfo infoUnit = new UnitInfo();
         PriceListBll BllPriceList = new PriceListBll();
         PriceListInfo infoPriceList = new PriceListInfo();
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoProduct = BllProductCreation.PriceListPopUpView(decProduct);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         decProduct = infoProduct.ProductId;
         decProductMain = infoProduct.ProductId;
         infoUnit = bllUnit.UnitViewForPriceListPopUp(decProduct);
         decUnitId = infoUnit.UnitId;
         txtUnitName.Text = infoUnit.UnitName;
         decPriceLevelId = infoPriceList.PricinglevelId;
         infoPricingLevel = BllPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProduct, decUnitId);
         decPriceLevelId = infoPricingLevel.PricinglevelId;
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         if (txtPricingLevel.Text == string.Empty)
         {
             infoPricingLevel = BllPricingLevel.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);
     }
 }
 /// <summary>
 /// On cell begin edit of dgvMultipleUnit
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvMultipleUnit_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         if (dgvMultipleUnit.CurrentCell.ColumnIndex == dgvMultipleUnit.Columns["dgvcmbmultipleunit"].Index)
         {
             ListObj = bllUnit.UnitViewAllWithoutPerticularId(decUnitIdExcludeToFillCombo);
             if (ListObj[0].Rows.Count > 0)
             {
                 if (dgvMultipleUnit.RowCount > 1)
                 {
                     int inGridRowCount = dgvMultipleUnit.RowCount;
                     for (int inI = 0; inI < inGridRowCount - 1; inI++)
                     {
                         if (inI != e.RowIndex)
                         {
                             int inTableRowcount = ListObj[0].Rows.Count;
                             for (int inJ = 0; inJ < inTableRowcount; inJ++)
                             {
                                 if (dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value != null && dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value.ToString() != "")
                                 {
                                     if (ListObj[0].Rows[inJ]["unitId"].ToString() == dgvMultipleUnit.Rows[inI].Cells["dgvcmbmultipleunit"].Value.ToString())
                                     {
                                         ListObj[0].Rows.RemoveAt(inJ);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 DataGridViewComboBoxCell dgvccProductMultipleUnit = (DataGridViewComboBoxCell)dgvMultipleUnit[dgvMultipleUnit.Columns["dgvcmbmultipleunit"].Index, e.RowIndex];
                 DataRow drow = ListObj[0].NewRow();
                 drow["unitName"] = string.Empty;
                 drow["unitId"] = 0;
                 ListObj[0].Rows.InsertAt(drow, 0);
                 dgvccProductMultipleUnit.DataSource = ListObj[0];
                 dgvccProductMultipleUnit.ValueMember = "unitId";
                 dgvccProductMultipleUnit.DisplayMember = "unitName";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PMU:29" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for Save and Edit
        /// </summary>  
        public void SaveOrEdit()
        {
            try
            {
                PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
                PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll();
                PurchaseReturnDetailsInfo infoPurchaseReturnDetails = new PurchaseReturnDetailsInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                //StockPostingSP spStockPosting = new StockPostingSP();
                StockPostingBll BllStockPosting = new StockPostingBll();
                UnitConvertionBll BllUnitConvertion = new UnitConvertionBll();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                ExchangeRateBll BllExchangeRate = new ExchangeRateBll();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
                AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                PurchaseReturnBilltaxInfo infoPurchaseReturnBillTax = new PurchaseReturnBilltaxInfo();

                SettingsBll BllSettings = new SettingsBll();
                UnitBll bllUnit = new UnitBll();
                List<DataTable> ListObj = new List<DataTable>();
                string strAgainstVoucherNo = string.Empty;
                string strAgainstInvoiceNo = string.Empty;
                decimal decPurchaseReturnMasterIds = 0;
                decimal decPurchaseMasterId = 0;
                decimal decDiscount = 0;
                decimal decExchangeRate = 0;
                decimal decDis = 0;

                if (isAutomatic)
                {
                    if (strVoucherNo != string.Empty)
                    {
                        infoPurchaseReturnMaster.VoucherNo = strVoucherNo;
                    }
                    if (txtReturnNo.Text != string.Empty)
                    {
                        infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text;
                    }
                }
                else
                {
                    infoPurchaseReturnMaster.VoucherNo = strVoucherNo;
                    infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text;
                }
                if (decPurchaseReturnVoucherTypeId != 0)
                {
                    infoPurchaseReturnMaster.VoucherTypeId = decPurchaseReturnVoucherTypeId;
                }
                infoPurchaseReturnMaster.SuffixPrefixId = (decPurchaseReturnSuffixPrefixId != 0) ? decPurchaseReturnSuffixPrefixId : 0;
                infoPurchaseReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                infoPurchaseReturnMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString());
                if (cmbInvoiceNo.SelectedValue != null && cmbInvoiceNo.Visible == true)
                {
                    infoPurchaseReturnMaster.PurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString()));
                    decPurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString()));
                }
                else
                {
                    infoPurchaseReturnMaster.PurchaseMasterId = 0;
                }
                infoPurchaseReturnMaster.ExchangeRateId = (cmbCurrency.SelectedValue != null) ? Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()) : 0;
                infoPurchaseReturnMaster.Narration = txtNarration.Text.Trim();
                infoPurchaseReturnMaster.UserId = PublicVariables._decCurrentUserId;
                infoPurchaseReturnMaster.LrNo = txtLrlNo.Text.Trim();
                infoPurchaseReturnMaster.TransportationCompany = txtTransportationCompany.Text.Trim();
                infoPurchaseReturnMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoPurchaseReturnMaster.TotalAmount = (txtTotalAmount.Text != string.Empty) ? Convert.ToDecimal(txtTotalAmount.Text) : 0;
                infoPurchaseReturnMaster.TotalTax = (lblTaxAmount.Text != string.Empty) ? Convert.ToDecimal(lblTaxAmount.Text) : 0;
                infoPurchaseReturnMaster.Discount = (txtBillDiscount.Text != string.Empty) ? Convert.ToDecimal(txtBillDiscount.Text) : 0;
                infoPurchaseReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoPurchaseReturnMaster.Extra1 = string.Empty;
                infoPurchaseReturnMaster.Extra2 = string.Empty;
                infoPurchaseReturnMaster.ExtraDate = DateTime.Now;
                infoPurchaseReturnMaster.GrandTotal = (txtGrandTotal.Text != string.Empty) ? Convert.ToDecimal(txtGrandTotal.Text) : 0;
                if (btnSave.Text == "Save")
                {
                    decPurchaseReturnMasterIds = BllPurchaseReturn.PurchaseReturnMasterAddWithReturnIdentity(infoPurchaseReturnMaster);
                }
                else
                {
                    infoPurchaseReturnMaster.PurchaseReturnMasterId = decPurchaseReturnMasterId;
                    decExchangeRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(infoPurchaseReturnMaster.ExchangeRateId);
                    BllPurchaseReturn.PurchaseReturnMasterEdit(infoPurchaseReturnMaster);
                    infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId);
                    BllLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseReturnVoucherTypeId);
                    bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseReturnVoucherTypeId);
                }

                infoLedgerPosting.Date = infoPurchaseReturnMaster.Date;
                infoLedgerPosting.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId;
                infoLedgerPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo;
                infoLedgerPosting.ChequeNo = string.Empty;
                infoLedgerPosting.ChequeDate = DateTime.Now;
                infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                infoLedgerPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo;
                infoLedgerPosting.Extra1 = string.Empty;
                infoLedgerPosting.Extra2 = string.Empty;

                infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.PurchaseAccount;
                infoLedgerPosting.Debit = 0;
                if (btnSave.Text == "Save")
                {
                    infoLedgerPosting.Credit = TotalNetAmountCalculation() * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
                    infoLedgerPosting.ExtraDate = DateTime.Now;
                }
                else
                {
                    infoLedgerPosting.Credit = TotalNetAmountCalculation();
                }
                BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);

                infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.LedgerId;
                if (btnSave.Text == "Save")
                {
                    infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text) * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
                    infoLedgerPosting.ExtraDate = DateTime.Now;
                }
                else
                {
                    infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text);
                }
                infoLedgerPosting.Credit = 0;
                BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);

                foreach (DataGridViewRow dgvrow in dgvPurchaseReturnTax.Rows)
                {
                    if (dgvrow.Cells["dgvtxtTaxId"].Value != null && dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty)
                    {
                        infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtledgerId"].Value.ToString());
                        infoLedgerPosting.Credit = (dgvrow.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(dgvrow.Cells["dgvtxtAmounts"].Value.ToString());
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.ExtraDate = DateTime.Now;
                        BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    }
                }

                if (txtBillDiscount.Text.Trim() != string.Empty)
                {
                    decDis = Convert.ToDecimal(txtBillDiscount.Text);
                }
                if (decDis >= 0)
                {
                    infoLedgerPosting.Debit = 0;
                    infoLedgerPosting.Credit = decDis;
                    infoLedgerPosting.LedgerId = 9;
                    infoLedgerPosting.ExtraDate = DateTime.Now;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                }

                if (btnSave.Text == "Update")
                {
                    infoPurchaseReturnMaster = BllPurchaseReturn.PurchaseReturnMasterView(decPurchaseReturnMasterId);
                    if (infoPurchaseReturnMaster.PurchaseMasterId == 0)
                    {
                        BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId);
                    }
                    if (infoPurchaseReturnMaster.PurchaseMasterId != 0)
                    {
                        infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId);
                        BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, strInvoiceNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId);
                    }
                }

                foreach (DataGridViewRow dgvrow in dgvPurchaseReturn.Rows)
                {
                    if (dgvrow.Cells["dgvtxtProductId"].Value != null && dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
                    {
                        infoPurchaseReturnDetails.ExtraDate = DateTime.Now;
                        infoPurchaseReturnDetails.Extra1 = string.Empty;
                        infoPurchaseReturnDetails.Extra2 = string.Empty;
                        infoPurchaseReturnDetails.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterId;
                        infoPurchaseReturnDetails.ProductId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtproductId"].Value));
                        infoPurchaseReturnDetails.Qty = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtqty"].Value));
                        infoPurchaseReturnDetails.Rate = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtrate"].Value));
                        if (btnSave.Text == "Save")
                        {
                            infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                            infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId);
                        }
                        else
                        {
                            if (Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value) == 0)
                            {
                                try
                                {
                                    infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                                }
                                catch
                                {
                                    infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString()));
                                }
                                infoPurchaseReturnDetails.UnitConversionId = BllUnitConvertion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId);
                            }
                            else
                            {
                                try
                                {
                                    infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                                }
                                catch
                                {
                                    infoPurchaseReturnDetails.UnitId = bllUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString()));
                                }
                            }
                            infoPurchaseReturnDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value);
                        }
                        infoPurchaseReturnDetails.Discount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtdiscount"].Value));
                        if (dgvrow.Cells["dgvcmbTax"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value) != string.Empty && dgvrow.Cells["dgvcmbTax"].Value as string != "NA")
                        {
                            infoPurchaseReturnDetails.TaxId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value));
                            if (strTaxComboFill != string.Empty)
                            {
                                infoPurchaseReturnDetails.TaxAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtTaxAmount"].Value));
                            }
                        }
                        else
                        {
                            infoPurchaseReturnDetails.TaxId = 0;
                        }
                        if (dgvrow.Cells["dgvcmbBatch"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbBatch"].Value) != string.Empty)
                        {
                            infoPurchaseReturnDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value);
                        }
                        else
                        {
                            infoPurchaseReturnDetails.GodownId = 0;
                        }
                        if (dgvrow.Cells["dgvcmbGodown"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbGodown"].Value) != string.Empty)
                        {
                            infoPurchaseReturnDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value);
                        }
                        else
                        {
                            infoPurchaseReturnDetails.RackId = 0;
                        }
                        if (dgvrow.Cells["dgvcmbRack"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbRack"].Value) != string.Empty)
                        {
                            infoPurchaseReturnDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value);
                        }
                        infoPurchaseReturnDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtgrossValue"].Value.ToString());
                        infoPurchaseReturnDetails.NetAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtNetAmount"].Value));
                        infoPurchaseReturnDetails.Amount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtAmount"].Value));
                        infoPurchaseReturnDetails.SlNo = Convert.ToInt32(Convert.ToString(dgvrow.Cells["dgvtxtSlNo"].Value));
                        infoPurchaseReturnDetails.PurchaseDetailsId = (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) ? Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value)) : 0;
                        if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value != null)
                        {
                            if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == string.Empty)
                            {
                                BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails);
                            }
                            else
                            {
                                infoPurchaseReturnDetails.PurchaseReturnDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString());
                                BllPurchaseReturn.PurchaseReturnDetailsEdit(infoPurchaseReturnDetails);
                            }
                        }
                        else
                        {
                            BllPurchaseReturn.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails);
                        }

                        if (btnSave.Text == "Save")
                        {
                            infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId);
                        }
                        infoStockPosting.Date = infoPurchaseReturnMaster.Date;
                        infoStockPosting.ProductId = infoPurchaseReturnDetails.ProductId;
                        infoStockPosting.BatchId = infoPurchaseReturnDetails.BatchId;
                        infoStockPosting.UnitId = infoPurchaseReturnDetails.UnitId;
                        infoStockPosting.GodownId = infoPurchaseReturnDetails.GodownId;
                        infoStockPosting.RackId = infoPurchaseReturnDetails.RackId;
                        decimal decConversionId = BllUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseReturnDetails.UnitConversionId);
                        //infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty / (decConversionId == 0 ? 1 : decConversionId);
                        infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty;
                        infoStockPosting.InwardQty = 0;
                        infoStockPosting.Rate = infoPurchaseReturnDetails.Rate;
                        infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        infoStockPosting.Extra1 = string.Empty;
                        infoStockPosting.Extra2 = string.Empty;
                        if (infoPurchaseReturnDetails.PurchaseDetailsId != 0)
                        {
                            infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                            infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo;
                            infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo;
                            infoStockPosting.VoucherNo = strVoucherNo;
                            infoStockPosting.InvoiceNo = txtReturnNo.Text.Trim();
                            infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId;
                            decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId;
                        }
                        else
                        {
                            infoStockPosting.AgainstVoucherTypeId = 0;
                            infoStockPosting.AgainstVoucherNo = "NA";
                            infoStockPosting.AgainstInvoiceNo = "NA";
                            infoStockPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo;
                            infoStockPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo;
                            infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId;
                            decAgainstVoucherTypeId = 0;
                        }
                        BllStockPosting.StockPostingAdd(infoStockPosting);
                    }
                }
                if (btnSave.Text == "Update")
                {
                    removePurchaseReturnDetails();
                }

                infoAccountLedger = bllAccountLedger.AccountLedgerView(infoPurchaseReturnMaster.LedgerId);
                if (infoAccountLedger.BillByBill == true)
                {
                    infoPartyBalance.Date = infoPurchaseReturnMaster.Date;
                    infoPartyBalance.LedgerId = infoPurchaseReturnMaster.LedgerId;
                    if (decAgainstVoucherTypeId != 0)
                    {
                        infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                        infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo;
                        infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                        infoPartyBalance.AgainstVoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId;
                        infoPartyBalance.AgainstVoucherNo = infoPurchaseReturnMaster.VoucherNo;
                        infoPartyBalance.AgainstInvoiceNo = infoPurchaseReturnMaster.InvoiceNo;
                        infoPartyBalance.ReferenceType = "Against";
                    }
                    else
                    {
                        infoPartyBalance.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId;
                        infoPartyBalance.VoucherNo = infoPurchaseReturnMaster.VoucherNo;
                        infoPartyBalance.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo;
                        infoPartyBalance.AgainstVoucherTypeId = 0;
                        infoPartyBalance.AgainstVoucherNo = "NA";
                        infoPartyBalance.AgainstInvoiceNo = "NA";
                        infoPartyBalance.ReferenceType = "New";
                    }
                    infoPartyBalance.Debit = infoPurchaseReturnMaster.TotalAmount;
                    infoPartyBalance.Credit = 0;
                    infoPartyBalance.CreditPeriod = 0;
                    infoPartyBalance.ExchangeRateId = infoPurchaseReturnMaster.ExchangeRateId;
                    infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                    infoPartyBalance.Extra1 = string.Empty;
                    infoPartyBalance.Extra2 = string.Empty;
                    BllPartyBalance.PartyBalanceAdd(infoPartyBalance);
                }

                foreach (DataGridViewRow item in dgvPurchaseReturnTax.Rows)
                {
                    if (item.Cells["dgvtxtTaxId"].Value != null)
                    {
                        if (Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()) > 0)
                        {
                            infoPurchaseReturnBillTax.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterIds;
                            infoPurchaseReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvtxtTaxId"].Value.ToString());
                            infoPurchaseReturnBillTax.TaxAmount = (item.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString());
                            infoPurchaseReturnBillTax.Extra1 = string.Empty;
                            infoPurchaseReturnBillTax.Extra2 = string.Empty;
                            BllPurchaseReturn.PurchaseReturnBilltaxAdd(infoPurchaseReturnBillTax);
                        }
                    }
                }
                if (btnSave.Text == "Save")
                {
                    Messages.SavedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decPurchaseReturnMasterIds);
                        }
                        else
                        {
                            Print(decPurchaseReturnMasterIds);
                        }
                    }
                    Clear();
                }
                else
                {
                    decDiscount = Convert.ToDecimal(txtBillDiscount.Text);
                    Messages.UpdatedMessage();
                    if (cbxPrintAfterSave.Checked)
                    {
                        if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                        {
                            PrintForDotMatrix(decPurchaseReturnMasterId);
                        }
                        else
                        {
                            Print(decPurchaseReturnMasterId);
                        }
                    }
                    if (frmPurchaseReturnRegisterObj != null)
                    {
                        frmPurchaseReturnRegisterObj.GridFill();
                        frmPurchaseReturnRegisterObj.Enabled = true;
                    }

                    if (ObjPurchaseReturnReport != null)
                    {
                        ObjPurchaseReturnReport.PurchaseReturnReportGridFill();
                        ObjPurchaseReturnReport.Enabled = true;
                    }
                    if (frmLedgerDetailsObj != null)
                    {
                        frmLedgerDetailsObj.LedgerDetailsView();
                        frmLedgerDetailsObj.Enabled = true;
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PR:49" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// On cell end edit of dgvMultipleUnit
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvMultipleUnit_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgvMultipleUnit.Columns[e.ColumnIndex].Name == "dgvcmbmultipleunit")
         {
             UnitBll bllUnit = new UnitBll();
             dgvMultipleUnit.Rows[e.RowIndex].Cells["dgvtxtunitname"].Value = bllUnit.UnitName(Convert.ToDecimal(dgvMultipleUnit.Rows[e.RowIndex].Cells["dgvcmbmultipleunit"].Value));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PMU:30" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Unit combo fill
 /// </summary>
 public void DGVUnitComboFill()
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         ListObj = bllUnit.UnitViewAll();
         dgvcmbUnit.DataSource = ListObj[0];
         DataRow dr = ListObj[0].NewRow();
         dr[2] = "NA";
         ListObj[0].Rows.InsertAt(dr, 0);
         dgvcmbUnit.ValueMember = "unitId";
         dgvcmbUnit.DisplayMember = "unitName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:07" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill default Unit
 /// </summary>
 public void DefaultUnitFillingInProductGrid()
 {
     UnitBll bllUnit = new UnitBll();
     DataTable dtbl = new DataTable();
     string strName = bllUnit.UnitName(decId);
     dtbl.Columns.Add("UnitName", typeof(string));
     dtbl.Columns.Add("UnitId", typeof(decimal));
     if (btnSave.Text == "Update")
     {
         strName = bllUnit.UnitName(Convert.ToDecimal(cmbUnit.SelectedValue));
         decId = Convert.ToDecimal(cmbUnit.SelectedValue);
     }
     DataRow dr = dtbl.NewRow();
     dr["UnitName"] = strName;
     dr["UnitId"] = decId;
     dtbl.Rows.Add(dr);
     DataRow drow = dtbl.NewRow();
     drow["UnitName"] = string.Empty;
     drow["UnitId"] = 0;
     dtbl.Rows.InsertAt(drow, 0);
     dgvcmbUnit.DataSource = dtbl;
     dgvcmbUnit.DisplayMember = "UnitName";
     dgvcmbUnit.ValueMember = "UnitId";
     for (int i = 0; i < dgvProductCreation.Rows.Count; i++)
     {
         if (!dgvProductCreation.Rows[i].IsNewRow)
         {
             dgvProductCreation.Rows[i].Cells["dgvcmbUnit"].Value = decId;
         }
     }
 }
 /// <summary>
 /// GridView Unit combobox fill
 /// </summary>
 public void UnitComboFill()
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         List<DataTable> ListObj = new List<DataTable>();
         ListObj = bllUnit.UnitViewAll();
         dgvcmbUnit.DataSource = ListObj[0];
         dgvcmbUnit.ValueMember = "unitId";
         dgvcmbUnit.DisplayMember = "unitName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO:3" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// To work on cmbMultipleUnit cell leave
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbMultipleUnit_Leave(object sender, EventArgs e)
        {
            try
            {
                if (cmbMultipleUnit.SelectedIndex == 1)
                {
                    UnitBll bllUnit = new UnitBll();
                    strProductName = txtName.Text.Trim();
                    decimal decUnitId = Convert.ToDecimal(cmbUnit.SelectedValue);
                    string strUnit = bllUnit.UnitName(Convert.ToDecimal(cmbUnit.SelectedValue));
                    frmProductMultipleUnit frmMultipleUnitObj = new frmProductMultipleUnit();
                    frmMultipleUnitObj.MdiParent = formMDI.MDIObj;
                    frmProductMultipleUnit open = Application.OpenForms["frmProductMultipleUnit"] as frmProductMultipleUnit;
                    if (open == null)
                    {
                        if (isMulUnitFromRgister && btnSave.Text == "Update")
                        {
                            if (!isCheck)
                            {
                                MultipleUnitTableForUpdate();
                                frmMultipleUnitObj.CallFromProdutCreationForUpadte(this, strProductName, decProductIdForEdit, dtblMulUnitForEdit, strUnitNameForGrid, decUnitIdForUpdate);
                                isGridHasToClear = true;
                            }
                            else
                            {
                                if (strProductName != string.Empty)
                                {
                                    if (cmbUnit.SelectedIndex != -1)
                                    {
                                        if (isSaveMulUnitCheck && (decUnitId == decUnitIdSelectedWhenMulUntCalled))
                                        {
                                            frmMultipleUnitObj.CallFromProdutCreationAgain(this, strProductName, decUnitId, strUnit, dtblMulUnit);

                                        }
                                        else
                                        {
                                            frmMultipleUnitObj.CallFromProdutCreation(this, strProductName, decUnitId, strUnit);

                                        }
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Select default unit");
                                        cmbMultipleUnit.SelectedIndex = 0;
                                        cmbUnit.Focus();
                                    }
                                }
                                else
                                {
                                    Messages.InformationMessage("Enter product name");
                                    cmbMultipleUnit.SelectedIndex = 0;
                                    txtName.Focus();
                                }
                            }
                        }
                        else
                        {
                            if (strProductName != string.Empty)
                            {
                                if (cmbUnit.SelectedIndex != -1)
                                {
                                    if (isSaveMulUnitCheck && (decUnitId == decUnitIdSelectedWhenMulUntCalled))
                                    {
                                        frmMultipleUnitObj.CallFromProdutCreationAgain(this, strProductName, decUnitId, strUnit, dtblMulUnit);

                                    }
                                    else
                                    {
                                        frmMultipleUnitObj.CallFromProdutCreation(this, strProductName, decUnitId, strUnit);

                                    }
                                }
                                else
                                {
                                    Messages.InformationMessage("Select default unit");
                                    cmbMultipleUnit.SelectedIndex = 0;
                                    cmbUnit.Focus();
                                }
                            }
                            else
                            {
                                Messages.InformationMessage("Enter product name");
                                cmbMultipleUnit.SelectedIndex = 0;
                                txtName.Focus();
                            }
                        }
                    }
                    else if (open != null)
                    {
                        if (open.WindowState == FormWindowState.Minimized)
                        {
                            open.WindowState = FormWindowState.Normal;
                        }
                    }
                    if (dtblForUnitIdInOpeNingStock != null && dtblForUnitIdInOpeNingStock.Rows.Count > 0)
                    {
                        dgvcmbUnit.DataSource = dtblForUnitIdInOpeNingStock;
                        dgvcmbUnit.DisplayMember = "unitName";
                        dgvcmbUnit.ValueMember = "dgvtxtunitId";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC:103" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to add new standard rate for the purticular product
 /// </summary>
 /// <param name="decProductId"></param>
 /// <param name="frmStandardRate"></param>
 public void CallFromStandardRate(decimal decProductId, frmStandardRate frmStandardRate)
 {
     try
     {
         base.Show();
         StandardrateObj = frmStandardRate;
         StandardrateObj.Enabled = false;
         ProductInfo infoProduct = new ProductInfo();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         UnitBll bllUnit = new UnitBll();
         UnitInfo infoUnit = new UnitInfo();
         infoProduct = BllProductCreation.ProductViewForStandardRate(decProductId);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         decProduct = infoProduct.ProductId;
         infoUnit = bllUnit.unitVieWForStandardRate(decProductId);
         decUnitId = infoUnit.UnitId;
         txtUnitName.Text = infoUnit.UnitName;
         txtProductName.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         BatchUnderProductComboFill(decProductId);
         GridFill(decProductId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SRP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Work on cmbOpeningStock Leave event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmbOpeningStock_Leave(object sender, EventArgs e)
 {
     try
     {
         if (cmbOpeningStock.SelectedIndex == 1)
         {
             if (cmbUnit.SelectedIndex == -1)
             {
                 Messages.InformationMessage("Select default unit");
                 cmbOpeningStock.SelectedIndex = 0;
                 cmbUnit.Focus();
             }
             if (!isstockPostingGridFil)
             {
                 if (isOpeningStockForUpdate)
                 {
                     OpeningStockGridFill();
                 }
                 if (isBatchForUpdate)
                 {
                     OpeningStockGridWithBathFill();
                 }
             }
             else
             {
                 if (!isGridHasToClear)
                 {
                     dgvProductCreation.Rows.Clear();
                     isOpeningStockChanged = true;
                 }
             }
             if (cmbMultipleUnit.SelectedIndex == 1 && dtblForUnitIdInOpeNingStock != null && dtblForUnitIdInOpeNingStock.Rows.Count > 0)
             {
                 UnitBll bllUnit = new UnitBll();
                 List<DataTable> ListObj = new List<DataTable>();
                 decId = Convert.ToDecimal(cmbUnit.SelectedValue);
                 strUnitNameForGrid = bllUnit.UnitName(decId);
                 DataRow dr = dtblForUnitIdInOpeNingStock.NewRow();
                 dr["dgvtxtUnitId"] = decId;
                 dr["unitName"] = strUnitNameForGrid;
                 dr["CnvertionRate"] = 0;
                 dr["quantities"] = 0;
                 dr["extra1"] = string.Empty;
                 dr["extra2"] = string.Empty;
                 dr["extraDate"] = DateTime.Now;
                 dtblForUnitIdInOpeNingStock.Rows.InsertAt(dr, (dtblForUnitIdInOpeNingStock.Rows.Count + 1));
                 dgvcmbUnit.DataSource = dtblForUnitIdInOpeNingStock;
                 dgvcmbUnit.DisplayMember = "unitName";
                 dgvcmbUnit.ValueMember = "dgvtxtunitId";
                 for (int i = 0; i < dgvProductCreation.Rows.Count; i++)
                 {
                     if (!dgvProductCreation.Rows[i].IsNewRow)
                     {
                         dgvProductCreation.Rows[i].Cells["dgvcmbUnit"].Value = dtblForUnitIdInOpeNingStock.Rows[0][1];
                     }
                 }
             }
             else if (decId != 0)
             {
                 DefaultUnitFillingInProductGrid();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:115" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to get the Details
        /// </summary>
        public void DeliveryNoteDetails()
        {
            try
            {
                ProductInfo infoProduct = new ProductInfo();
                ProductCreationBll BllProductCreation = new ProductCreationBll();
                DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo();
                StockPostingInfo infoStockPosting = new StockPostingInfo();
                StockPostingBll BllStockPosting = new StockPostingBll();
                // StockPostingSP spStockPosting = new StockPostingSP();
                //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP();
                DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
                UnitBll bllUnit = new UnitBll();

                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 = BllProductCreation.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;
                        bllDeliveryNote.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails);
                    }
                    else
                    {
                        infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit;
                        infoDeliveryNoteDetails.DeliveryNoteDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value);
                        infoProduct = BllProductCreation.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(bllUnit.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());
                        bllDeliveryNote.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;
                    BllStockPosting.StockPostingAdd(infoStockPosting);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// To Get Default Product Values
 /// </summary>
 /// <param name="inindex"></param>
 /// <param name="decproductId"></param>
 public void ProductDefaultValues(int inindex, decimal decproductId)
 {
     try
     {
         UnitBll bllUnit = new UnitBll();
         isValueChange = false;
         infoProduct = BllProductCreation.ProductView(decproductId);
         dgvProduct.Rows[inindex].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode;
         dgvProduct.Rows[inindex].Cells["dgvtxtProductName"].Value = infoProduct.ProductName;
         TransactionsGeneralFillBll objTransactionsGeneralFillBll = new TransactionsGeneralFillBll();
        List<DataTable> listObj = new List<DataTable>();
         listObj = objTransactionsGeneralFillBll.UnitViewAllByProductId(dgvProduct, decproductId.ToString(), inindex);
         BatchBll BllBatch = new BatchBll();
         BllBatch.BatchViewbyProductIdForComboFillInGrid(decproductId, dgvProduct, inindex);
         isValueChange = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("RO40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }