Beispiel #1
0
        /// <summary>
        /// Function to reset form
        /// </summary>
        ///
        public void invoiceNumberfill()
        {
            decimal   decVoucherTypeId = 0;
            DataTable dtblc            = new DataTable();

            try
            {
                if (cmpvoucherType.SelectedIndex > -1)
                {
                    if (cmpvoucherType.SelectedValue.ToString() != "System.Data.DataRowView" && cmpvoucherType.Text != "System.Data.DataRowView")
                    {
                        SalesReturnMasterSP mastersp = new SalesReturnMasterSP();
                        decVoucherTypeId = Convert.ToDecimal(cmpvoucherType.SelectedValue.ToString());
                        dtblc            = mastersp.invoicenumberviewallforvouchertypeIdforSR(decVoucherTypeId);
                        DataRow drow = dtblc.NewRow();
                        drow["invoiceNo"] = "All";
                        dtblc.Rows.InsertAt(drow, 0);
                        cmbInvoiceNo.DataSource    = dtblc;
                        cmbInvoiceNo.ValueMember   = "salesReturnMasterId";
                        cmbInvoiceNo.DisplayMember = "invoiceNo";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SRR16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to reset form
        /// </summary>
        /// 
        public void invoiceNumberfill()
        {
            decimal decVoucherTypeId = 0;
            DataTable dtblc = new DataTable();
            try
            {
                if (cmpvoucherType.SelectedIndex > -1)
                {
                    if (cmpvoucherType.SelectedValue.ToString() != "System.Data.DataRowView" && cmpvoucherType.Text != "System.Data.DataRowView")
                    {

                        SalesReturnMasterSP mastersp = new SalesReturnMasterSP();
                        decVoucherTypeId = Convert.ToDecimal(cmpvoucherType.SelectedValue.ToString());
                        dtblc = mastersp.invoicenumberviewallforvouchertypeIdforSR(decVoucherTypeId);
                        DataRow drow = dtblc.NewRow();
                        drow["invoiceNo"] = "All";
                        dtblc.Rows.InsertAt(drow, 0);
                        cmbInvoiceNo.DataSource = dtblc;
                        cmbInvoiceNo.ValueMember = "salesReturnMasterId";
                        cmbInvoiceNo.DisplayMember = "invoiceNo";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SRR16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }


        }
Beispiel #3
0
 /// <summary>
 /// Function to generate Voucher number as per settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         TransactionsGeneralFill obj = new TransactionsGeneralFill();
         SalesReturnMasterSP spSalesReturn = new SalesReturnMasterSP();
         string strPrefix = string.Empty;
         string strSuffix = string.Empty;
         string strReturnNo = string.Empty;
         string tableName = "SalesReturnMaster";
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decSalesReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != spSalesReturn.SalesReturnMasterGetMaxPlusOne(decSalesReturnVoucherTypeId))
         {
             strVoucherNo = spSalesReturn.SalesReturnMasterGetMax(decSalesReturnVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decSalesReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (spSalesReturn.SalesReturnMasterGetMax(decSalesReturnVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decSalesReturnVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decSalesReturnVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decSalesReturnSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             strReturnNo = strPrefix + strVoucherNo + strSuffix;
             txtReturnNo.Text = strReturnNo;
             txtReturnNo.ReadOnly = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR69:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Function to use the SalesReturn VoucherType ComboFill
 /// </summary>
 /// <param name="ledgerIdFromCashOrPartyCombo"></param>
 public void SalesReturnVoucherTypeComboFill(decimal ledgerIdFromCashOrPartyCombo)
 {
     try
     {
         SalesReturnMasterSP salesReturnMasterSP = new SalesReturnMasterSP();
         DataTable dtbl = new DataTable();
         dtbl = salesReturnMasterSP.SalesReturnVoucherTypeComboFill(ledgerIdFromCashOrPartyCombo);
         cmbVoucherType.DataSource = dtbl;
         if (cmbVoucherType.DataSource != null)
         {
             DataRow dr = dtbl.NewRow();
             dr["voucherTypeId"] = 0;
             dr["voucherTypeName"] = "NA";
             dtbl.Rows.InsertAt(dr, 0);
             cmbVoucherType.ValueMember = "voucherTypeId";
             cmbVoucherType.DisplayMember = "voucherTypeName";
             cmbVoucherType.SelectedIndex = -1;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR56:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #5
0
 /// <summary>
 /// FunctionforVouchertypecombofill
 /// </summary>
 public void VoucherTypeCombofill()
 {
     try
     {
         DataTable dtbl = new DataTable();
         SalesReturnMasterSP spmaster = new SalesReturnMasterSP();
         dtbl = spmaster.vouchertypecompofill();
         cmbVoucherType.DataSource = dtbl;
         cmbVoucherType.ValueMember = "voucherTypeId";
         cmbVoucherType.DisplayMember = "voucherTypeName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR:67" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Function to use the Combo Selection By using InvoiceNo
 /// </summary>
 public void ComboSelectionByInvoiceNo()
 {
     DataTable dtblComboSelection = new DataTable();
     SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
     try
     {
         if (!isEnterIntoComboSelectn == false)
         {
             if (cmbInvoiceNo.SelectedIndex != -1)
             {
                 if (cmbInvoiceNo.SelectedValue.ToString() != "System.Data.DataRowView" && cmbInvoiceNo.Text != "System.Data.DataRowView")
                 {
                     DGVGodownComboFill();
                     DGVUnitComboFill();
                     decTotalAmounForSaveCheck = 0;
                     SalesMasterSP spSaleMaster = new SalesMasterSP();
                     dgvSalesReturn.Rows.Clear();
                     dtblComboSelection = spSaleMaster.SalesMasterViewByInvoiceNoForComboSelection(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()));
                     if (dtblComboSelection != null)
                     {
                         cmbPricingLevel.SelectedValue = dtblComboSelection.Rows[0]["pricingLevelId"];
                         cmbSalesAccount.SelectedValue = dtblComboSelection.Rows[0]["salesAccount"];
                         cmbSalesAccount.Enabled = true;
                         txtTransportationComp.Text = dtblComboSelection.Rows[0]["transportationCompany"].ToString();
                         txtLRNo.Text = dtblComboSelection.Rows[0]["lrNo"].ToString();
                     }
                     DataTable dtblSalesReturnGrideFill = spSalesDetails.SalesDetailsViewForSalesReturnGrideFill(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()), salesReturnMasterId);
                     dtblSalesInvoice = dtblSalesReturnGrideFill;
                     foreach (DataRow drowDetails in dtblSalesReturnGrideFill.Rows)
                     {
                         decimal decproductId = Convert.ToDecimal(drowDetails["productId"].ToString());
                         TaxGridFill();
                         dgvSalesReturn.Rows.Add();
                         if (drowDetails["S.No"].ToString() != string.Empty)
                         {
                             dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvSNo"].Value = drowDetails["S.No"].ToString();
                         }
                         if (drowDetails["salesDetailsId"].ToString() != string.Empty)
                         {
                             dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = drowDetails["salesDetailsId"].ToString();
                         }
                         else
                         {
                             dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = 0;
                         }
                         if (drowDetails["productId"].ToString() != string.Empty)
                         {
                             dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value = drowDetails["productId"].ToString();
                             DataTable dtbl = spSalesDetails.SalesDetailsViewForSalesReturnGrideFill1(Convert.ToDecimal(drowDetails["productId"].ToString()));
                             foreach (DataRow drowDetails1 in dtbl.Rows)
                             {
                                 if (dtblComboSelection.Rows[0]["voucherTypeId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["voucherTypeId"].Value = Convert.ToDecimal(dtblComboSelection.Rows[0]["voucherTypeId"].ToString());
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["voucherTypeId"].Value = 0;
                                 }
                                 if (dtblComboSelection.Rows[0]["voucherNo"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["voucherNo"].Value = dtblComboSelection.Rows[0]["voucherNo"].ToString();
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["voucherNo"].Value = 0;
                                 }
                                 if (dtblComboSelection.Rows[0]["invoiceNo"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["invoiceNo"].Value = dtblComboSelection.Rows[0]["invoiceNo"].ToString();
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["invoiceNo"].Value = 0;
                                 }
                                 if (drowDetails1["barcode"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextBarcode"].Value = drowDetails1["barcode"].ToString();
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextBarcode"].ReadOnly = true;
                                 }
                                 if (drowDetails1["productCode"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductCode"].Value = drowDetails1["productCode"].ToString();
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductCode"].ReadOnly = true;
                                 }
                                 if (drowDetails1["productName"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductName"].Value = drowDetails1["productName"].ToString();
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductName"].ReadOnly = true;
                                 }
                                 if (drowDetails["unitId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ReadOnly = true;
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = 1;
                                 }
                                 if (drowDetails["goDownId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = Convert.ToDecimal(drowDetails["goDownId"].ToString());
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].ReadOnly = false;
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = 1;
                                 }
                                 RackComboFill(Convert.ToDecimal(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value), dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].ColumnIndex);
                                 if (drowDetails["rackId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString());
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = 1;
                                 }
                                 BatchComboFill(Convert.ToDecimal(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value), dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ColumnIndex);
                                 if (drowDetails["batchId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ReadOnly = true;
                                 }
                                 if (drowDetails["unitConversionId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = 0;
                                 }
                                 dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["conversionRate"].Value = drowDetails["conversionRate"].ToString();
                                 if (drowDetails["taxId"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTaxId"].Value = 0;
                                     if (Convert.ToDecimal(drowDetails["taxId"].ToString()) != 0)
                                     {
                                         dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTaxId"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString());
                                         dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString());
                                         strTaxRate = spSalesReturnMaster.TaxRateFindForTaxAmmountCalByTaxId(Convert.ToDecimal(drowDetails["taxId"].ToString()));
                                     }
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = 1;
                                 }
                                 if (drowDetails["qty"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                     decQty = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = 0;
                                     decQty = 0;
                                 }
                                 if (drowDetails["rate"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = Convert.ToDecimal(drowDetails["rate"].ToString());
                                     decRate = Convert.ToDecimal(drowDetails["rate"].ToString());
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = 0.00;
                                     decRate = 0;
                                 }
                                 if (drowDetails["grossAmount"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["grossAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true;
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = 0.00;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true;
                                 }
                                 if (drowDetails["discount"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountPercentage"].Value = 0.00;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = 0.00;
                                 }
                                 if (drowDetails["netAmount"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["netAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true;
                                     txtBillDiscount.Text = "0.00";
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = 0.00;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true;
                                 }
                                 if (drowDetails["taxAmount"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["taxAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = false;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = 0.00;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = true;
                                 }
                                 if (drowDetails["amount"].ToString() != string.Empty)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = Math.Round(Convert.ToDecimal(drowDetails["amount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true;
                                 }
                                 else
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = 0.00;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true;
                                 }
                                 if (cmbInvoiceNo.Visible == true)
                                 {
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextBarcode"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductCode"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductName"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextQty"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbUnit"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbGodown"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbRack"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbBatch"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextRate"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextDiscountPercentage"].ReadOnly = true;
                                     dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbTax"].ReadOnly = true;
                                 }
                                 foreach (DataGridViewRow item1 in dgvSalesReturn2.Rows)
                                 {
                                     if (item1.Cells["dgvTextTaxId"].Value != null)
                                     {
                                         if (dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value != null && dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value.ToString() != string.Empty)
                                         {
                                             if (dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value.ToString() == item1.Cells["dgvTextTaxId"].Value.ToString())
                                             {
                                                 item1.Cells["dgvTextAmount"].Value = dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         else
                         {
                             dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["productId"].Value = 0;
                         }
                     }
                     txtNarration.Text = dtblComboSelection.Rows[0]["narration"].ToString();
                     GrossValueCalculation(dgvSalesReturn.Rows.Count - 2);
                     DiscountCalculationfordiscountpercentage(dgvSalesReturn.Rows.Count - 2, 12);
                     DiscountCalculation(dgvSalesReturn.Rows.Count - 2, 13);
                     TaxAmountCalculation(dgvSalesReturn.Rows.Count - 2);
                     TotalAmtCalculation();
                     TotalBillTaxCalculation();
                     GrandTotalCalculation();
                     taxamountfill();
                     taxAndGridTotalAmountCalculation(dgvSalesReturn.Rows.Count - 2);
                     CessTaxamountCalculation();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR46:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Function to use the SalesReturn InvoiceNo ComboFill
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <param name="salesReturnMasterId"></param>
 /// <param name="decledgerId"></param>
 public void SalesReturnInvoiceNoComboFill(decimal decVoucherTypeId, decimal salesReturnMasterId, decimal decledgerId)
 {
     try
     {
         SalesReturnMasterSP salesReturnMasterSP = new SalesReturnMasterSP();
         DataTable dtbl = new DataTable();
         dtbl = salesReturnMasterSP.SalesReturnInvoiceNoComboFill(decVoucherTypeId, salesReturnMasterId, decledgerId);
         cmbInvoiceNo.DataSource = dtbl;
         if (cmbInvoiceNo.DataSource != null)
         {
             cmbInvoiceNo.ValueMember = "salesMasterId";
             cmbInvoiceNo.DisplayMember = "invoiceNo";
             cmbInvoiceNo.SelectedIndex = -1;
         }
         isEnterIntoComboSelectn = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR55:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #8
0
        /// <summary>
        /// FunctionToRemoveIncmpletedRow
        /// </summary>
        /// <returns></returns>
        public bool RemoveIncompleteRowsFromGrid()
        {
            SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
            bool isOk = true;
            try
            {
                string strMessage = "Rows";
                int inC = 0, inForFirst = 0;
                int inRowcount = dgvSalesReturn.RowCount;
                int inLastRow = 1;
                if (inRowcount <= 2)
                {
                    if (dgvSalesReturn.Rows[0].Cells["dgvTextProductName"].Value == null || dgvSalesReturn.Rows[0].Cells["dgvTextProductName"].Value.ToString() == string.Empty ||
                        dgvSalesReturn.Rows[0].Cells["dgvTextProductCode"].Value == null || dgvSalesReturn.Rows[0].Cells["dgvTextProductCode"].Value.ToString() == string.Empty ||
                         dgvSalesReturn.Rows[0].Cells["dgvTextQty"].Value == null || dgvSalesReturn.Rows[0].Cells["dgvTextQty"].Value.ToString().Trim() == string.Empty ||
                          Convert.ToDecimal(dgvSalesReturn.Rows[0].Cells["dgvTextQty"].Value.ToString()) == 0 || dgvSalesReturn.Rows[0].Cells["dgvTextRate"].Value == null || dgvSalesReturn.Rows[0].Cells["dgvTextRate"].Value.ToString().Trim() == string.Empty ||

                        (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && Convert.ToDecimal(dgvSalesReturn.CurrentRow.Cells["dgvTextRate"].Value) == 0))
                    {
                        MessageBox.Show("Can't save purchase return without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvSalesReturn.ClearSelection();
                        dgvSalesReturn.Focus();
                        isOk = false;
                    }
                }
                else
                {
                    foreach (DataGridViewRow dgvrowCur in dgvSalesReturn.Rows)
                    {
                        if (inLastRow < inRowcount)
                        {
                            if (dgvrowCur.HeaderCell.Value != null)
                            {
                                if (dgvrowCur.HeaderCell.Value.ToString() == "X" || dgvrowCur.Cells["dgvTextProductName"].Value == null)
                                {
                                    isOk = false;
                                    if (inC == 0)
                                    {
                                        strMessage = strMessage + Convert.ToString(dgvrowCur.Index + 1);
                                        inForFirst = dgvrowCur.Index;
                                        inC++;
                                    }
                                    else
                                    {
                                        strMessage = strMessage + ", " + Convert.ToString(dgvrowCur.Index + 1);
                                    }
                                }
                            }
                        }
                        inLastRow++;
                    }
                    inLastRow = 1;
                    if (!isOk)
                    {
                        strMessage = strMessage + " contains invalid entries. Do you want to continue?";
                        if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            isOk = true;
                            for (int inK = 0; inK < dgvSalesReturn.Rows.Count; inK++)
                            {
                                if (dgvSalesReturn.Rows[inK].HeaderCell.Value != null && dgvSalesReturn.Rows[inK].HeaderCell.Value.ToString() == "X")
                                {
                                    if (!dgvSalesReturn.Rows[inK].IsNewRow)
                                    {
                                        dgvSalesReturn.Rows.RemoveAt(inK);
                                        inK--;

                                    }
                                }
                            }
                        }
                        else
                        {
                            isOk = false;
                            dgvSalesReturn.Rows[inForFirst].Cells["dgvTextProductName"].Selected = true;
                            dgvSalesReturn.CurrentCell = dgvSalesReturn.Rows[inForFirst].Cells["dgvTextProductName"];
                            dgvSalesReturn.Focus();
                        }
                    }
                }
                //SerialNo();
            }
            catch (Exception ex)
            {
                MessageBox.Show("SR:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return isOk;
        }
Beispiel #9
0
        /// <summary>
        /// Function to save an item into table
        /// </summary>
        public void Save()
        {
            ExchangeRateSP spExchangeRate = new ExchangeRateSP();
            SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
            SalesReturnDetailsSP spSalesReturnDetails = new SalesReturnDetailsSP();
            StockPostingSP spStockPosting = new StockPostingSP();
            LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
            PartyBalanceSP spPartyBalance = new PartyBalanceSP();
            UnitConvertionSP spUnitConvertion = new UnitConvertionSP();
            UnitSP spUnit = new UnitSP();
            try
            {
                if (txtReturnNo.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Enter return no", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtReturnNo.Focus();
                }
                else if (spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Save")
                {
                    Messages.InformationMessage("Return  number already exist");
                    txtReturnNo.Focus();
                }
                //else if ((txtReturnNo .Text!=ManualReturnNo)&&(spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Update"))
                //{
                //    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 = spExchangeRate.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;
                        spSalesReturnMaster.SalesReturnMasterEdit(infoSalesReturnMaster);
                        spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text);
                        spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text);
                        spStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decSalesReturnVoucherTypeId);
                        spSalesReturnBillTax.SalesReturnBillTaxDeleteBySalesReturnMasterId(decSalesReturnMasterId);
                    }
                    else
                    {
                        decSalesReturnMasterId = spSalesReturnMaster.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);
                            spSalesReturnDetails.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());
                                spSalesReturnDetails.SalesReturnDetailsEdit(infoSalesReturnDetailsInfo);
                            }
                            else
                            {
                                decSalesReturnDetailId = spSalesReturnDetails.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 = spProduct.ProductView(infoSalesReturnDetailsInfo.ProductId);
                                DataTable dtbl = spUnitConvertion.DGVUnitConvertionRateByUnitId(infoSalesReturnDetailsInfo.UnitId, infoProduct.ProductName);
                                foreach (DataRow drowDetails in dtbl.Rows)
                                {
                                    decUnitConvertionRate = Convert.ToDecimal(drowDetails["conversionRate"].ToString());
                                }
                                strQuantities = spUnit.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;
                            spStockPosting.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;
                    spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    infoLedgerPosting.LedgerId = infoSalesReturnMaster.SalesAccount;
                    infoLedgerPosting.Debit = (decNetTotal * decExchangeRate);
                    infoLedgerPosting.Credit = 0;
                    spLedgerPosting.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);
                        spLedgerPosting.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;
                    spPartyBalance.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;
                            spSalesReturnBillTax.SalesReturnBillTaxAdd(infoSalesReturnBillTax);
                        }
                    }
                    if (btnSave.Text == "Save")
                    {
                        Messages.SavedMessage();
                        if (cbxPrintAfterSave.Checked == true)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decSalesReturnMasterId);
                            }
                            else
                            {
                                Print(decSalesReturnMasterId);
                            }
                        }
                        clear();
                    }
                    else
                    {
                        Messages.UpdatedMessage();
                        if (cbxPrintAfterSave.Checked == true)
                        {
                            if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                            {
                                PrintForDotMatrix(decSalesReturnMasterId);
                            }
                            else
                            {
                                Print(decSalesReturnMasterId);
                            }
                        }
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SR36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #10
0
 /// <summary>
 /// print function
 /// </summary>
 /// <param name="decSalesReturnMasterId"></param>
 public void Print(decimal decSalesReturnMasterId)
 {
     try
     {
         SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
         DataSet dsSalesReturn = spSalesReturnMaster.SalesReturnPrinting(decSalesReturnMasterId);
         frmReport frmReport = new frmReport();
         frmReport.MdiParent = formMDI.MDIObj;
         frmReport.SalesReturnPrinting(dsSalesReturn);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR31:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Function to delete an item from database
        /// </summary>
        public void Delete()
        {
            try
            {
                SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
                spSalesReturnMaster.SalesReturnDelete(salesReturnMasterId, decSalesReturnVoucherTypeId, strVoucherNo);
                Messages.DeletedMessage();
                if (objFromSalesReturnRegister != null)
                {
                    if (isFromOther)
                    {
                        this.Close();
                        objFromSalesReturnRegister.Enabled = true;
                        objFromSalesReturnRegister.SalesReturnGrideFill();
                    }
                }
                else if (objFromSalesReturnReport != null)
                {
                    if (isFromOther)
                    {
                        this.Close();
                        objFromSalesReturnReport.Enabled = true;
                        objFromSalesReturnReport.SalesReturnReportGrideFill();
                    }
                }
                else if (objVoucherSearch != null)
                {

                    objVoucherSearch.GridFill();
                    this.Close();
                }
                else if (frmDayBookObj != null)
                {
                    this.Close();
                }
                else
                {
                    clear();
                }
                if (frmLedgerDetailsObj != null)
                {
                    this.Close();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("SR30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #12
0
        /// <summary>
        /// FunctionToreturn fromregisterclick
        /// </summary>
        public void FillRegisterOrReport()
        {
            SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP();
            SalesReturnDetailsSP spSalesReturnDetails = new SalesReturnDetailsSP();
            try
            {
                isFromOther = true;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                CashOrPartyUnderSundryDebitorComboFill(cmbCashOrParty);
                DataTable dtblSalesMaster = new DataTable();
                DataTable dtblSalesReturnMaster = new DataTable();
                dtblSalesReturnMaster = spSalesReturnMaster.SalesReturnMasterViewBySalesReturnMasterId(salesReturnMasterId);
                decSalesReturnMasterId = salesReturnMasterId;
                DecSalesReturnVoucherTypeId = Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString());
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                infoVoucherType = spVoucherType.VoucherTypeView(DecSalesReturnVoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;
                if (infoVoucherType.MethodOfVoucherNumbering == "Manual")
                {
                    txtReturnNo.Text = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString();
                    ManualReturnNo = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString();
                    txtReturnNo.Enabled = true;
                }
                else
                {
                    txtReturnNo.Text = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString();
                    txtReturnNo.Enabled = false;
                }
                if (dtblSalesReturnMaster.Rows.Count > 0)
                {
                    txtDate.Text = dtblSalesReturnMaster.Rows[0]["date"].ToString();
                    dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                    if (dtblSalesReturnMaster.Rows[0]["grandTotal"].ToString() != string.Empty)
                    {
                        txtGrandTotal.Text = dtblSalesReturnMaster.Rows[0]["grandTotal"].ToString();
                    }
                    strVoucherNo = dtblSalesReturnMaster.Rows[0]["voucherNo"].ToString();
                    if (dtblSalesReturnMaster.Rows[0]["ledgerId"].ToString() != string.Empty)
                    {
                        cmbCashOrParty.SelectedValue = dtblSalesReturnMaster.Rows[0]["ledgerId"].ToString();
                    }
                    cmbVoucherTypeComboFill();
                    if (dtblSalesReturnMaster.Rows[0]["SMVoucherTypeId"].ToString() != string.Empty)
                    {
                        cmbVoucherType.SelectedValue = dtblSalesReturnMaster.Rows[0]["SMVoucherTypeId"].ToString();
                    }
                    else
                    {
                        cmbVoucherType.SelectedValue = 0;
                    }
                    cmbInvoiceComboFill();
                    if (dtblSalesReturnMaster.Rows[0]["pricingLevelId"].ToString() != string.Empty)
                    {
                        cmbPricingLevel.SelectedValue = dtblSalesReturnMaster.Rows[0]["pricingLevelId"].ToString();
                    }
                    if (dtblSalesReturnMaster.Rows[0]["salesAccount"].ToString() != string.Empty)
                    {
                        cmbSalesAccount.SelectedValue = dtblSalesReturnMaster.Rows[0]["salesAccount"].ToString();
                    }
                    if (dtblSalesReturnMaster.Rows[0]["employeeId"].ToString() != string.Empty)
                    {
                        cmbSalesMan.SelectedValue = dtblSalesReturnMaster.Rows[0]["employeeId"].ToString();
                    }
                    if (dtblSalesReturnMaster.Rows[0]["exchangeRateId"].ToString() != string.Empty)
                    {
                        cmbCurrency.SelectedValue = dtblSalesReturnMaster.Rows[0]["exchangeRateId"].ToString();
                    }
                    txtNarration.Text = dtblSalesReturnMaster.Rows[0]["narration"].ToString();
                    txtLRNo.Text = dtblSalesReturnMaster.Rows[0]["lrNo"].ToString();
                    txtTransportationComp.Text = dtblSalesReturnMaster.Rows[0]["transportationCompany"].ToString();
                    if (dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString() != string.Empty && Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString()) != 0)
                    {
                        cmbInvoiceNo.SelectedValue = dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString();
                        decinvoiceno = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString());
                        dtblSalesReturnMasterViewBySMID = spSalesReturnMaster.SalesReturnMasterViewBySalesMasterId(Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString()));
                    }
                    isInvoiceFill = false;
                    if (dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString() != string.Empty)
                    {
                        decSalesReturnVoucherTypeId = Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString());
                    }
                    TaxGridFill();
                    if (cmbInvoiceNo.SelectedValue != null)
                    {
                        infoSalesMaster = spSalesMaster.SalesMasterViewBySalesMasterId(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()));
                    }
                    DataTable dtblSalesReturnDetails = new DataTable();
                    dtblSalesReturnDetails = spSalesReturnDetails.SalesReturnDetailsViewBySalesReturnMasterId(salesReturnMasterId);
                    dtblSalesInvoice = dtblSalesReturnDetails;
                    foreach (DataRow drowDetails in dtblSalesReturnDetails.Rows)
                    {
                        dgvSalesReturn.Rows.Add();
                        if (drowDetails["salesReturnDetailsId"].ToString() != string.Empty)
                        {
                            dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesReturnDetailsId"].Value = Convert.ToDecimal(drowDetails["salesReturnDetailsId"].ToString());
                        }
                        if (drowDetails["salesDetailsId"].ToString() != string.Empty)
                        {
                            dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = drowDetails["salesDetailsId"].ToString();
                        }
                        else
                        {
                            dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = 0;
                        }
                        if (drowDetails["productId"].ToString() != string.Empty)
                        {
                            dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value = drowDetails["productId"].ToString();
                            DataTable dtbl = spSalesDetails.SalesReturnGrideFillNewByProductId(Convert.ToDecimal(drowDetails["productId"].ToString()));
                            foreach (DataRow drowDetails1 in dtbl.Rows)
                            {
                                if (drowDetails1["barcode"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextBarcode"].Value = drowDetails1["barcode"].ToString();
                                }
                                if (drowDetails1["productCode"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductCode"].Value = drowDetails1["productCode"].ToString();
                                }
                                if (drowDetails1["productName"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductName"].Value = drowDetails1["productName"].ToString();
                                }
                                if (cmbInvoiceNo.Visible == true)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ReadOnly = true;
                                }
                                if (drowDetails["unitId"].ToString() != string.Empty)
                                {
                                    decProductId = decimal.Parse(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value.ToString());
                                    UnitComboFill(decProductId, dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ColumnIndex);
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = 1;
                                }
                                if (drowDetails["goDownId"].ToString() != string.Empty)
                                {
                                    DGVGodownComboFill();
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = Convert.ToDecimal(drowDetails["goDownId"].ToString());
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = 1;
                                }
                                if (drowDetails["rackId"].ToString() != string.Empty)
                                {
                                    RackComboFill(Convert.ToDecimal(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value.ToString()), dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].ColumnIndex);
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString());
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = 1;
                                }
                                if (drowDetails["batchId"].ToString() != string.Empty)
                                {
                                    BatchComboFill(decProductId, dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ColumnIndex);
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                                }
                                if (drowDetails["unitConversionId"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = 0;
                                }
                                if (dtblSalesReturnMaster.Rows[0]["SMVoucherTypeId"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ReadOnly = true;
                                }
                                if (drowDetails["taxId"].ToString() != string.Empty)
                                {
                                    if (Convert.ToDecimal(drowDetails["taxId"].ToString()) != 0)
                                    {
                                        dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTaxId"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString());
                                        dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString());
                                        strTaxRate = spSalesReturnMaster.TaxRateFindForTaxAmmountCalByTaxId(Convert.ToDecimal(drowDetails["taxId"].ToString()));
                                    }
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = 1;
                                }
                                if (drowDetails["qty"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    decQty = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = 0.00;
                                    decQty = 0;
                                }
                                if (drowDetails["rate"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = Math.Round(Convert.ToDecimal(drowDetails["rate"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    decRate = Convert.ToDecimal(drowDetails["rate"].ToString());
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = 0.00;
                                    decRate = 0;
                                }
                                if (drowDetails["grossAmount"].ToString() != string.Empty)
                                {
                                    //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["grossAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    // dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true;
                                }
                                else
                                {
                                    //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = 0.00;
                                    //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true;
                                }
                                if (drowDetails["discount"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountPercentage"].Value = 0.00;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = 0.00;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountPercentage"].Value = 0.00;
                                }
                                if (drowDetails["netAmount"].ToString() != string.Empty)
                                {
                                    // dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["netAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    //  dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true;
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = 0.00;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true;
                                }
                                if (drowDetails["taxAmount"].ToString() != string.Empty)
                                {
                                    //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = false;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["taxAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = true;
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = 0.00;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = true;
                                }
                                if (drowDetails["amount"].ToString() != string.Empty)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = Math.Round(Convert.ToDecimal(drowDetails["amount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true;
                                }
                                else
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = 0.00;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true;
                                }
                                if (cmbInvoiceNo.Visible == true)
                                {
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextBarcode"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductCode"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductName"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextQty"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbUnit"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbGodown"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbRack"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbBatch"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextRate"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextDiscountPercentage"].ReadOnly = true;
                                    dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbTax"].ReadOnly = true;
                                }
                                dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["conversionRate"].Value = drowDetails["conversionRate"].ToString();
                                foreach (DataGridViewRow item1 in dgvSalesReturn2.Rows)
                                {
                                    if (item1.Cells["dgvTextTaxId"].Value != null)
                                    {
                                        if (dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value.ToString() == item1.Cells["dgvTextTaxId"].Value.ToString())
                                        {
                                            item1.Cells["dgvTextAmount"].Value = dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value = 0;
                        }
                        TotalAmountCalculation();
                    }
                    if (!isSalesReturnFormActive)
                    {
                        dtblTaxGride = spSalesReturnBillTax.TaxDetailsViewBySalesReturnMasterId(salesReturnMasterId);
                        foreach (DataRow item1 in dtblTaxGride.Rows)
                        {
                            dgvSalesReturn2.Rows.Add();
                            dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextTaxName"].Value = item1["taxName"].ToString();
                            dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextAmount"].Value = Math.Round(Convert.ToDecimal(item1["taxAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
                            dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvRate"].Value = item1["rate"].ToString();
                            dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextTaxId"].Value = item1["taxId"].ToString();
                        }
                    }
                    txtBillDiscount.Text = Convert.ToString(Math.Round(Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces));
                    SerialNo2();

                    TotalBillTaxCalculation();
                    CessTaxamountCalculation();
                    TotalTaxAmtCalculation();
                    if (txtBillDiscount.Text != string.Empty)
                    {
                        decimal decDiscount = Convert.ToDecimal(txtBillDiscount.Text);
                        decimal decTotalAmt = Convert.ToDecimal(txtTotalAmount.Text);
                        if (decTotalAmt > decDiscount)
                        {
                            decimal decGrandTotal = decTotalAmt + decTotalBillTaxAmount + decTotalCessTaxamount - decDiscount;
                            decGrandTotal = Math.Round(decGrandTotal, PublicVariables._inNoOfDecimalPlaces);
                            txtGrandTotal.Text = decGrandTotal.ToString();
                        }
                    }
                    // SerialNo();
                }
                else
                {
                    MessageBox.Show("No record exists", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SR28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }