public ServiceMasterInfo GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo(decimal decServiceMasterId, decimal decVoucherNo) { ServiceMasterInfo servicemasterinfo = new ServiceMasterInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam3 = new SqlParameter(); sprmparam3 = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal); sprmparam3.Value = decServiceMasterId; sprmparam3 = sccmd.Parameters.Add("@voucherNo", SqlDbType.Decimal); sprmparam3.Value = decVoucherNo; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { servicemasterinfo.VoucherTypeId = decimal.Parse(((DbDataReader)sdrreader)["voucherTypeId"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(servicemasterinfo); }
public void ServiceMasterEdit(ServiceMasterInfo servicemasterinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ServiceMasterEdit", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam20 = new SqlParameter(); sprmparam20 = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.ServiceMasterId; sprmparam20 = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.SuffixPrefixId; sprmparam20 = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam20.Value = servicemasterinfo.Date; sprmparam20 = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.LedgerId; sprmparam20 = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.TotalAmount; sprmparam20 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam20.Value = servicemasterinfo.Narration; sprmparam20 = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.UserId; sprmparam20 = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int); sprmparam20.Value = servicemasterinfo.CreditPeriod; sprmparam20 = sccmd.Parameters.Add("@serviceAccount", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.ServiceAccount; sprmparam20 = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.ExchangeRateId; sprmparam20 = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.EmployeeId; sprmparam20 = sccmd.Parameters.Add("@customer", SqlDbType.VarChar); sprmparam20.Value = servicemasterinfo.Customer; sprmparam20 = sccmd.Parameters.Add("@discount", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.Discount; sprmparam20 = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.GrandTotal; sprmparam20 = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.VoucherTypeId; sprmparam20 = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam20.Value = servicemasterinfo.FinancialYearId; sprmparam20 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam20.Value = servicemasterinfo.ExtraDate; sprmparam20 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam20.Value = servicemasterinfo.Extra1; sprmparam20 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam20.Value = servicemasterinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
/// <summary> /// Function to Update values in ServiceMaster Table /// </summary> /// <param name="servicemasterinfo"></param> public void ServiceMasterEdit(ServiceMasterInfo servicemasterinfo) { try { spServiceMaster.ServiceMasterEdit(servicemasterinfo); } catch (Exception ex) { MessageBox.Show("AL35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ServiceMasterInfo ServiceMasterView(decimal serviceMasterId) { ServiceMasterInfo servicemasterinfo = new ServiceMasterInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ServiceMasterView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal); sprmparam2.Value = serviceMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { servicemasterinfo.ServiceMasterId = decimal.Parse(((DbDataReader)sdrreader)["serviceMasterId"].ToString()); servicemasterinfo.VoucherNo = ((DbDataReader)sdrreader)["voucherNo"].ToString(); servicemasterinfo.InvoiceNo = ((DbDataReader)sdrreader)["invoiceNo"].ToString(); servicemasterinfo.SuffixPrefixId = decimal.Parse(((DbDataReader)sdrreader)["suffixPrefixId"].ToString()); servicemasterinfo.Date = DateTime.Parse(((DbDataReader)sdrreader)["date"].ToString()); servicemasterinfo.LedgerId = decimal.Parse(((DbDataReader)sdrreader)["ledgerId"].ToString()); servicemasterinfo.TotalAmount = decimal.Parse(((DbDataReader)sdrreader)["totalAmount"].ToString()); servicemasterinfo.Narration = ((DbDataReader)sdrreader)["narration"].ToString(); servicemasterinfo.UserId = decimal.Parse(((DbDataReader)sdrreader)["userId"].ToString()); servicemasterinfo.CreditPeriod = int.Parse(((DbDataReader)sdrreader)["creditPeriod"].ToString()); servicemasterinfo.ServiceAccount = decimal.Parse(((DbDataReader)sdrreader)["serviceAccount"].ToString()); servicemasterinfo.ExchangeRateId = decimal.Parse(((DbDataReader)sdrreader)["exchangeRateId"].ToString()); servicemasterinfo.EmployeeId = Convert.ToDecimal(((DbDataReader)sdrreader)["employeeId"].ToString()); servicemasterinfo.Customer = ((DbDataReader)sdrreader)["customer"].ToString(); servicemasterinfo.Discount = decimal.Parse(((DbDataReader)sdrreader)["discount"].ToString()); servicemasterinfo.GrandTotal = decimal.Parse(((DbDataReader)sdrreader)["grandTotal"].ToString()); servicemasterinfo.VoucherTypeId = decimal.Parse(((DbDataReader)sdrreader)["voucherTypeId"].ToString()); servicemasterinfo.FinancialYearId = decimal.Parse(((DbDataReader)sdrreader)["financialYearId"].ToString()); servicemasterinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)["extraDate"].ToString()); servicemasterinfo.Extra1 = ((DbDataReader)sdrreader)["extra1"].ToString(); servicemasterinfo.Extra2 = ((DbDataReader)sdrreader)["extra2"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(servicemasterinfo); }
/// <summary> /// Function to get particular values from ServiceMaster Table based on the parameter /// </summary> /// <param name="serviceMasterId"></param> /// <returns></returns> public ServiceMasterInfo ServiceMasterView(decimal serviceMasterId) { ServiceMasterInfo servicemasterinfo = new ServiceMasterInfo(); try { servicemasterinfo = spServiceMaster.ServiceMasterView(serviceMasterId); } catch (Exception ex) { MessageBox.Show("AL35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(servicemasterinfo); }
/// <summary> /// Function to insert values to ServiceMaster Table and return corresponding row's id /// </summary> /// <param name="servicemasterinfo"></param> /// <returns></returns> public decimal ServiceMasterAddReturnWithIdentity(ServiceMasterInfo servicemasterinfo) { decimal decIdentity = 0; try { decIdentity = spServiceMaster.ServiceMasterAddReturnWithIdentity(servicemasterinfo); } catch (Exception ex) { MessageBox.Show("AL33:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decIdentity); }
/// <summary> /// Function to fill the fields for edit or delete /// </summary> public void FillFunction() { try { ServicesBll BllService = new ServicesBll(); //ServiceMasterSP spServiceMaster = new ServiceMasterSP(); ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); decServiceMasterId = decMasterId; infoServiceMaster = BllService.ServiceMasterView(decServiceMasterId); infoVoucherType = BllVoucherType.VoucherTypeView(infoServiceMaster.VoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(infoServiceMaster.VoucherTypeId); txtInvoiceNumber.ReadOnly = true; strVoucherNo = infoServiceMaster.VoucherNo.ToString(); txtInvoiceNumber.Text = infoServiceMaster.InvoiceNo; txtCreditPeriod.Text = infoServiceMaster.CreditPeriod.ToString(); strInvoiceNo = infoServiceMaster.InvoiceNo.ToString(); decServiceSuffixPrefixId = Convert.ToDecimal(infoServiceMaster.SuffixPrefixId.ToString()); DecServicetVoucherTypeId = Convert.ToDecimal(infoServiceMaster.VoucherTypeId.ToString()); int inDecimalPlace = PublicVariables._inNoOfDecimalPlaces; txtVoucherDate.Text = infoServiceMaster.Date.ToString("dd-MMM-yyyy"); dtpVoucherDate.Value = Convert.ToDateTime(infoServiceMaster.Date); cmbCashParty.SelectedValue = infoServiceMaster.LedgerId; cmbServiceAC.SelectedValue = infoServiceMaster.ServiceAccount; cmbSalesman.SelectedValue = infoServiceMaster.EmployeeId; txtCustomer.Text = infoServiceMaster.Customer; txtNarration.Text = infoServiceMaster.Narration; List<DataTable> listObjServiceDetails = new List<DataTable>(); listObjServiceDetails = BllService.ServiceDetailsViewWithMasterId(decServiceMasterId); for (int i = 0; i < listObjServiceDetails[0].Rows.Count; i++) { dgvServiceVoucher.Rows.Add(); dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceDetailsId"].ToString()); dgvServiceVoucher.Rows[i].Cells["dgvtxtServiceMasterId"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceMasterId"].ToString()); dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceId"].ToString()); dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value = listObjServiceDetails[0].Rows[i]["measure"].ToString(); dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value = listObjServiceDetails[0].Rows[i]["amount"].ToString(); decimal decDetailsId1 = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceDetailsId"].ToString()); decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, DecServicetVoucherTypeId); dgvServiceVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); } cmbCurrency.SelectedValue = infoServiceMaster.ExchangeRateId; txtTotalAmount.Text = infoServiceMaster.TotalAmount.ToString(); txtDiscount.Text = infoServiceMaster.Discount.ToString(); txtGrandTotal.Text = infoServiceMaster.GrandTotal.ToString(); infoPartyBalance = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherTypeId(DecServicetVoucherTypeId, strVoucherNo, infoServiceMaster.Date); decPartyBalanceId = infoPartyBalance.PartyBalanceId; } catch (Exception ex) { MessageBox.Show("SV 32 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit the service voucher /// </summary> /// <param name="decServiceMasterId"></param> public void EditFunction(decimal decServiceMasterId) { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; decimal decLedgerPostingId1 = 0; decimal decLedgerPostingId2 = 0; List<DataTable> listObjLedgerPostingId = new List<DataTable>(); listObjLedgerPostingId = BllService.LedgerPostingIdByServiceMaasterId(decServiceMasterId); decLedgerPostingId1 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[0]["ledgerPostingId"].ToString()); decLedgerPostingId2 = Convert.ToDecimal(listObjLedgerPostingId[0].Rows[1]["ledgerPostingId"].ToString()); for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { infoServiceMaster.ServiceMasterId = decServiceMasterId; infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; //------------------deleting removed rows----------------------------------------// BankReconciliationBll BllBankReconciliation = new BankReconciliationBll(); foreach (object obj in strArrOfRemove) { string str = Convert.ToString(obj); BllService.ServiceDetailsDelete(Convert.ToDecimal(str)); } BllService.ServiceMasterEdit(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); if (dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceDetailsId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString()); infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); BllService.ServiceDetailsEdit(infoServiceDetails); } else { infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); decConvertRate += decAmount * decSelectedCurrencyRate; } } decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId1, decLedgerId, decCredit, decDebit); decCredit = decConvertRate; decDebit = 0; decLedgerId = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); LedgerPostingEdit(decLedgerPostingId2, decLedgerId, decCredit, decDebit); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.PartyBalanceId = decPartyBalanceId; infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceEdit(infoPartyBalance); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } this.Close(); if (frmServiceVoucherRegisterObj != null) { frmServiceVoucherRegisterObj.Show(); frmServiceVoucherRegisterObj.GridFill(); } else if (frmServiceReportObj != null) { frmServiceReportObj.Show(); frmServiceReportObj.GridFill(); } } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); } } catch (Exception ex) { MessageBox.Show("SV 24 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the service voucher /// </summary> public void SaveFunction() { try { ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo(); ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo(); ServicesBll BllService = new ServicesBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); int inRowCount = dgvServiceVoucher.RowCount; int inValue = 0; for (int ini = 0; ini < inRowCount - 1; ini++) { if (dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[ini].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { inValue++; } } if (inValue > 0) { txtDiscount.Enabled = true; infoServiceMaster.InvoiceNo = txtInvoiceNumber.Text; if (isAutomatic) { infoServiceMaster.VoucherNo = strVoucherNo; } else { infoServiceMaster.VoucherNo = Convert.ToString(BllService.ServiceMasterGetMax(DecServicetVoucherTypeId) + 1); } infoServiceMaster.SuffixPrefixId = decServiceSuffixPrefixId; infoServiceMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoServiceMaster.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoServiceMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoServiceMaster.Narration = txtNarration.Text.Trim(); infoServiceMaster.UserId = PublicVariables._decCurrentUserId; infoServiceMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoServiceMaster.ServiceAccount = Convert.ToDecimal(cmbServiceAC.SelectedValue.ToString()); decimal decExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());//spExchangeRate.GetExchangeRateByCurrencyId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoServiceMaster.ExchangeRateId = decExchangeRateId; infoServiceMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoServiceMaster.Customer = txtCustomer.Text.Trim(); infoServiceMaster.Discount = Convert.ToDecimal(txtDiscount.Text.Trim()); infoServiceMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoServiceMaster.VoucherTypeId = DecServicetVoucherTypeId; infoServiceMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoServiceMaster.ExtraDate = PublicVariables._dtCurrentDate; infoServiceMaster.Extra1 = string.Empty; infoServiceMaster.Extra2 = string.Empty; decServiceMasterId = BllService.ServiceMasterAddReturnWithIdentity(infoServiceMaster); infoServiceDetails.ServiceMasterId = decServiceMasterId; infoServiceDetails.Extra1 = string.Empty; infoServiceDetails.Extra2 = string.Empty; infoServiceDetails.ExtraDate = PublicVariables._dtCurrentDate; for (int i = 0; i < inRowCount - 1; i++) { if (dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString() != string.Empty) { infoServiceDetails.ServiceId = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value.ToString()); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString() != string.Empty) { infoServiceDetails.Measure = dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value.ToString(); } if (dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { infoServiceDetails.Amount = Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); decAmount += Convert.ToDecimal(dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value); } decServiceDetailsId = BllService.ServiceDetailsAddReturnWithIdentity(infoServiceDetails); } decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(infoServiceMaster.ExchangeRateId); decConvertRate = decAmount * decSelectedCurrencyRate; decCredit = 0; decDebit = decConvertRate; decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); LedgerPosting(decLedgerId, decCredit, decDebit, decServiceDetailsId, infoServiceMaster.VoucherNo); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(cmbCashParty.Text)); if (decI > 0) { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString()); infoPartyBalance.VoucherTypeId = DecServicetVoucherTypeId; infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.InvoiceNo = strInvoiceNo; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = decAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); infoPartyBalance.ExchangeRateId = decExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decServiceMasterId); } else { Print(decServiceMasterId, infoServiceMaster.ExchangeRateId); } } Clear(); } else { Messages.InformationMessage("Can't save Service Voucher without atleast one ledger with complete details"); dgvServiceVoucher.ClearSelection(); dgvServiceVoucher.CurrentCell = dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"]; dgvServiceVoucher.Rows[0].Cells["dgvcmbParticulars"].Selected = true; } } catch (Exception ex) { MessageBox.Show("SV 19 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public decimal ServiceMasterAddReturnWithIdentity(ServiceMasterInfo servicemasterinfo) { decimal decIdentity = 0m; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("ServiceMasterAddReturnWithIdentity", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam21 = new SqlParameter(); sprmparam21 = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.VoucherNo; sprmparam21 = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.InvoiceNo; sprmparam21 = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.SuffixPrefixId; sprmparam21 = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam21.Value = servicemasterinfo.Date; sprmparam21 = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.LedgerId; sprmparam21 = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.TotalAmount; sprmparam21 = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.Narration; sprmparam21 = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.UserId; sprmparam21 = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int); sprmparam21.Value = servicemasterinfo.CreditPeriod; sprmparam21 = sccmd.Parameters.Add("@serviceAccount", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.ServiceAccount; sprmparam21 = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.ExchangeRateId; sprmparam21 = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.EmployeeId; sprmparam21 = sccmd.Parameters.Add("@customer", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.Customer; sprmparam21 = sccmd.Parameters.Add("@discount", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.Discount; sprmparam21 = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.GrandTotal; sprmparam21 = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.VoucherTypeId; sprmparam21 = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam21.Value = servicemasterinfo.FinancialYearId; sprmparam21 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam21.Value = servicemasterinfo.ExtraDate; sprmparam21 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.Extra1; sprmparam21 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam21.Value = servicemasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } return(decIdentity); }