Beispiel #1
0
 /// <summary>
 ///  Ledger grid cell begin edit for Combo box item fill and remove from the list once it has selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvSalesInvoiceLedger_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     try
     {
         if (dgvSalesInvoice.RowCount > 1)
         {
             DataTable dtbl = new DataTable();
             AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
             if (dgvSalesInvoiceLedger.CurrentCell.ColumnIndex == dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index)
             {
                 dtbl = SpAccountLedger.AccountLedgerViewForAdditionalCost();
                 if (dtbl.Rows.Count > 0)
                 {
                     if (dgvSalesInvoiceLedger.RowCount > 1)
                     {
                         int inGridRowCount = dgvSalesInvoiceLedger.RowCount;
                         for (int inI = 0; inI < inGridRowCount - 1; inI++)
                         {
                             if (inI != e.RowIndex)
                             {
                                 int inTableRowcount = dtbl.Rows.Count;
                                 for (int inJ = 0; inJ < inTableRowcount; inJ++)
                                 {
                                     if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty)
                                     {
                                         if (dtbl.Rows[inJ]["ledgerId"].ToString() == dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString())
                                         {
                                             dtbl.Rows.RemoveAt(inJ);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvSalesInvoiceLedger[dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index, e.RowIndex];
                     dgvccVoucherType.DataSource = dtbl;
                     dgvccVoucherType.ValueMember = "ledgerId";
                     dgvccVoucherType.DisplayMember = "ledgerName";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 106" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Fill function from coming from register or report or other forms
 /// </summary>
 public void FillRegisterOrReport()
 {
     SalesMasterSP spSalesMaster = new SalesMasterSP();
     SalesDetailsSP spSalesDetails = new SalesDetailsSP();
     VoucherTypeSP spVoucherType = new VoucherTypeSP();
     SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP();
     try
     {
         isFromEditMode = true;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtInvoiceNo.ReadOnly = true;
         DataTable dtblMaster = spSalesMaster.SalesInvoiceSalesMasterViewBySalesMasterId(decSalesInvoiceIdToEdit);
         DecSalesInvoiceVoucherTypeId = Convert.ToDecimal(dtblMaster.Rows[0]["voucherTypeId"].ToString());
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         infoVoucherType = spVoucherType.VoucherTypeView(DecSalesInvoiceVoucherTypeId);
         this.Text = infoVoucherType.VoucherTypeName;
         txtDate.Text = dtblMaster.Rows[0]["date"].ToString();
         dtpDate.Value = DateTime.Parse(txtDate.Text);
         CurrencyComboFill();
         txtInvoiceNo.Text = dtblMaster.Rows[0]["invoiceNo"].ToString();
         txtCreditPeriod.Text = dtblMaster.Rows[0]["creditPeriod"].ToString();
         strVoucherNo = dtblMaster.Rows[0]["voucherNo"].ToString();
         decSalseInvoiceSuffixPrefixId = Convert.ToDecimal(dtblMaster.Rows[0]["suffixPrefixId"].ToString());
         isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(DecSalesInvoiceVoucherTypeId);
         cmbCashOrParty.SelectedValue = dtblMaster.Rows[0]["ledgerId"].ToString();
         cmbSalesAccount.SelectedValue = dtblMaster.Rows[0]["salesAccount"].ToString();
         cmbSalesMan.SelectedValue = dtblMaster.Rows[0]["employeeId"].ToString();
         txtCustomer.Text = dtblMaster.Rows[0]["customerName"].ToString();
         txtTransportCompany.Text = dtblMaster.Rows[0]["transportationCompany"].ToString();
         txtVehicleNo.Text = dtblMaster.Rows[0]["lrNo"].ToString();
         txtNarration.Text = dtblMaster.Rows[0]["narration"].ToString();
         cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString());
         txtTotalAmount.Text = dtblMaster.Rows[0]["totalAmount"].ToString();
         lblTaxTotalAmount.Text = dtblMaster.Rows[0]["taxAmount"].ToString();
         cmbPricingLevel.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["pricingLevelId"].ToString());
         if (dtblMaster.Rows[0]["quotationMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against Quotation";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = dtblMaster.Rows[0]["quotationMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Quotation No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else if (dtblMaster.Rows[0]["orderMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against SalesOrder";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = dtblMaster.Rows[0]["orderMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Order No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else if (dtblMaster.Rows[0]["deliveryNoteMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against Delivery Note";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = dtblMaster.Rows[0]["deliveryNoteMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Delivery Note No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else
         {
             cmbSalesMode.SelectedText = "NA";
         }
         if (txtInvoiceNo.Enabled)
         {
             txtDate.Focus();
         }
         else
         {
             txtInvoiceNo.Focus();
         }
         DataTable dtblDetails = new DataTable();
         dtblDetails = spSalesDetails.SalesInvoiceSalesDetailsViewBySalesMasterId(decSalesInvoiceIdToEdit);
         dgvSalesInvoiceTaxComboFill();
         dgvSalesInvoice.Rows.Clear();
         for (int i = 0; i < dtblDetails.Rows.Count; i++)
         {
             dgvSalesInvoice.Rows.Add();
             IsSetGridValueChange = false;
             dgvSalesInvoice.Rows[i].HeaderCell.Value = string.Empty;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["salesDetailsId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSlno"].Value = dtblDetails.Rows[i]["slNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].Value = dtblDetails.Rows[i]["barcode"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].Value = dtblDetails.Rows[i]["productCode"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].Value = dtblDetails.Rows[i]["productName"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value = dtblDetails.Rows[i]["productId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].Value = dtblDetails.Rows[i]["brandName"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value = dtblDetails.Rows[i]["qty"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = dtblDetails.Rows[i]["purchaseRate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceAmount"].Value = dtblDetails.Rows[i]["amount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceGrossValue"].Value = dtblDetails.Rows[i]["grossAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["unitId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value = dtblDetails.Rows[i]["rate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["godownId"].ToString());
             RackComboFill(Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()), i, dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].ColumnIndex);
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["rackId"].ToString());
             if (dtblDetails.Rows[i]["batchId"] != null && dtblDetails.Rows[i]["batchId"].ToString() != string.Empty)
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["batchId"].ToString());
             }
             else
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = string.Empty;
             }
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceMrp"].Value = dtblDetails.Rows[i]["mrp"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesRate"].Value = dtblDetails.Rows[i]["salesRate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value = dtblDetails.Rows[i]["discount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceNetAmount"].Value = dtblDetails.Rows[i]["netAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceTaxName"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["taxId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = dtblDetails.Rows[i]["taxAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = dtblDetails.Rows[i]["unitConversionId"].ToString();
             lblTotalQuantitydisplay.Text = dtblDetails.Rows[i]["qty"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSISalesOrderDetailsId"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["orderDetailsId"].ToString());  // here get fill the grid colum for the editing prps
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = dtblDetails.Rows[i]["deliveryNoteDetailsId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = dtblDetails.Rows[i]["quotationDetailsId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = Convert.ToDecimal(dtblDetails.Rows[i]["voucherTypeRefNo"].ToString());  // here get fill the grid colum for the editing prps
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = dtblDetails.Rows[i]["voucherRefNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = dtblDetails.Rows[i]["invoiceRefNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].ReadOnly = true;
             if (cmbSalesMode.SelectedIndex != 0)
             {
                 strVoucherNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString();
                 strInvoiceNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString();
                 decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value);
             }
             GrossValueCalculation(i);
             DiscountCalculation(i, dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].ColumnIndex);
             taxAndGridTotalAmountCalculation(i);
             decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value.ToString());
             decCurrentConversionRate = Convert.ToDecimal(dtblDetails.Rows[i]["conversionRate"].ToString());
             UnitConversionCalc(i);
             if (cmbSalesModeOrderNo.Visible == true)
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true;
             }
         }
         DataTable dtblAdditionalCost = new DataTable();
         dtblAdditionalCost = spSalesMaster.SalesInvoiceAdditionalCostViewByVoucherNoUnderVoucherType(DecSalesInvoiceVoucherTypeId, strVoucherNo);
         for (int i = 0; i < dtblAdditionalCost.Rows.Count; i++)
         {
             dgvSalesInvoiceLedger.Rows.Add();
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCostId"].Value = dtblAdditionalCost.Rows[i]["additionalCostId"].ToString();
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvCmbAdditionalCostledgerName"].Value = Convert.ToDecimal(dtblAdditionalCost.Rows[i]["ledgerId"].ToString());
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCoastledgerAmount"].Value = dtblAdditionalCost.Rows[i]["amount"].ToString();
             DataTable dtblAdcostForView = new DataTable();
             AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
             dtblAdcostForView = SpAccountLedger.AccountLedgerViewForAdditionalCost();
             DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvSalesInvoiceLedger[dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index, i];
             dgvccVoucherType.DataSource = dtblAdcostForView;
             dgvccVoucherType.ValueMember = "ledgerId";
             dgvccVoucherType.DisplayMember = "ledgerName";
         }
         DataTable dtblDrOrCr = spSalesMaster.salesinvoiceAdditionalCostCheckdrOrCrforSiEdit(DecSalesInvoiceVoucherTypeId, strVoucherNo);
         if (dtblDrOrCr.Rows.Count > 0)
         {
             if (Convert.ToDecimal(dtblDrOrCr.Rows[0]["credit"].ToString()) != 0)
             {
                 cmbCashOrbank.SelectedValue = Convert.ToDecimal(dtblDrOrCr.Rows[0]["ledgerId"].ToString());
                 cmbCashOrbank.Visible = true;
                 lblcashOrBank.Visible = true;
                 cmbDrorCr.SelectedIndex = 0;
                 decBankOrCashIdForEdit = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString());
             }
             else
             {
                 cmbDrorCr.SelectedIndex = 1;
             }
         }
         taxGridFill();
         DataTable dtblTax = new DataTable();
         dtblTax = spSalesBillTax.SalesInvoiceSalesBillTaxViewAllBySalesMasterId(decSalesInvoiceIdToEdit);
         foreach (DataGridViewRow dgvrowTax in dgvSalesInvoiceTax.Rows)
         {
             for (int ini = 0; ini < dtblTax.Rows.Count; ini++)
             {
                 if (dgvrowTax.Cells["dgvtxtTtaxId"].Value != null && dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty)
                 {
                     decimal decId = Convert.ToDecimal(dtblTax.Rows[ini]["taxId"].ToString());
                     if (dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() == decId.ToString())
                     {
                         dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = dtblTax.Rows[ini]["taxAmount"].ToString();
                         break;
                     }
                     else
                     {
                         dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = "0.00";
                     }
                 }
             }
         }
         LedgerGridTotalAmountCalculation();
         SiGridTotalAmountCalculation();
         txtGrandTotal.Text = dtblMaster.Rows[0]["grandTotal"].ToString();
         txtBillDiscount.Text = dtblMaster.Rows[0]["billDiscount"].ToString();
         bool isPartyBalanceRef = false;
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         PartyBalanceSP spPartyBalance = new PartyBalanceSP();
         isPartyBalanceRef = spAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, DecSalesInvoiceVoucherTypeId);
         if (isPartyBalanceRef)
         {
             cmbCashOrParty.Enabled = false;
         }
         else
         {
             cmbCashOrParty.Enabled = true;
         }
         //if (!spPartyBalance.PartyBalanceCheckReference(DecSalesInvoiceVoucherTypeId, strVoucherNo))
         //{
         //    cmbCashOrParty.Enabled = false;
         //}
         //else
         //{
         //    cmbCashOrParty.Enabled = true;
         //}
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 77" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }