Esempio n. 1
0
        /// <summary>
        /// Function to get particular values from ServiceDetails Table based on the parameter
        /// </summary>
        /// <param name="serviceDetailsId"></param>
        /// <returns></returns>
        public ServiceDetailsInfo ServiceDetailsView(decimal serviceDetailsId)
        {
            ServiceDetailsInfo servicedetailsinfo = new ServiceDetailsInfo();
            SqlDataReader      sdrreader          = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceDetailsView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
                sprmparam.Value = serviceDetailsId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    servicedetailsinfo.ServiceDetailsId = decimal.Parse(sdrreader[0].ToString());
                    servicedetailsinfo.ServiceMasterId  = decimal.Parse(sdrreader[1].ToString());
                    servicedetailsinfo.ServiceId        = decimal.Parse(sdrreader[2].ToString());
                    servicedetailsinfo.Measure          = sdrreader[3].ToString();
                    servicedetailsinfo.Amount           = decimal.Parse(sdrreader[4].ToString());
                    servicedetailsinfo.ExtraDate        = DateTime.Parse(sdrreader[5].ToString());
                    servicedetailsinfo.Extra1           = sdrreader[6].ToString();
                    servicedetailsinfo.Extra2           = sdrreader[7].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(servicedetailsinfo);
        }
Esempio n. 2
0
        /// <summary>
        /// Function to insert values to ServiceDetails Table and return corresponding row's id
        /// </summary>
        /// <param name="servicedetailsinfo"></param>
        /// <returns></returns>
        public decimal ServiceDetailsAddReturnWithIdentity(ServiceDetailsInfo servicedetailsinfo)
        {
            decimal decIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceDetailsAddReturnWithIdentity", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.ServiceMasterId;
                sprmparam       = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.ServiceId;
                sprmparam       = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Measure;
                sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
                sprmparam.Value = servicedetailsinfo.Amount;
                sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value = servicedetailsinfo.ExtraDate;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = servicedetailsinfo.Extra2;
                decIdentity     = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decIdentity);
        }
Esempio n. 3
0
 /// <summary>
 /// Function to insert values to ServiceDetails Table
 /// </summary>
 /// <param name="servicedetailsinfo"></param>
 public void ServiceDetailsAdd(ServiceDetailsInfo servicedetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceDetailsAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceDetailsId;
         sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceMasterId;
         sprmparam       = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceId;
         sprmparam       = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Measure;
         sprmparam       = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.Amount;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicedetailsinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Function to insert values to ServiceDetails Table and return corresponding row's id
 /// </summary>
 /// <param name="servicedetailsinfo"></param>
 /// <returns></returns>
 public decimal ServiceDetailsAddReturnWithIdentity(ServiceDetailsInfo servicedetailsinfo)
 {
     decimal decIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceDetailsAddReturnWithIdentity", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceMasterId;
         sprmparam = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceId;
         sprmparam = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Measure;
         sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.Amount;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicedetailsinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra2;
         decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decIdentity;
 }
Esempio n. 5
0
 /// <summary>
 /// Function to insert values to ServiceDetails Table
 /// </summary>
 /// <param name="servicedetailsinfo"></param>
 public void ServiceDetailsAdd(ServiceDetailsInfo servicedetailsinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceDetailsAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceDetailsId;
         sprmparam = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceMasterId;
         sprmparam = sccmd.Parameters.Add("@serviceId", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.ServiceId;
         sprmparam = sccmd.Parameters.Add("@measure", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Measure;
         sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal);
         sprmparam.Value = servicedetailsinfo.Amount;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicedetailsinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicedetailsinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Function to save the service voucher
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo();
         ServiceMasterSP spServiceMaster = new ServiceMasterSP();
         ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo();
         ServiceDetailsSP spServiceDetails = new ServiceDetailsSP();
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
         ExchangeRateSP spExchangeRate = new ExchangeRateSP();
         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(spServiceMaster.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 = spServiceMaster.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 = spServiceDetails.ServiceDetailsAddReturnWithIdentity(infoServiceDetails);
             }
             decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(infoServiceMaster.ExchangeRateId);
             decConvertRate = decAmount * decSelectedCurrencyRate;
             decCredit = 0;
             decDebit = decConvertRate;
             decLedgerId = Convert.ToDecimal(cmbCashParty.SelectedValue.ToString());
             LedgerPosting(decLedgerId, decCredit, decDebit, decServiceDetailsId, infoServiceMaster.VoucherNo);
             AccountLedgerSP spAccountLedger = new AccountLedgerSP();
             decimal decI = Convert.ToDecimal(spAccountLedger.AccountGroupIdCheck(cmbCashParty.Text));
             if (decI > 0)
             {
                 PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
                 PartyBalanceSP spPartyBalance = new PartyBalanceSP();
                 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;
                 spPartyBalance.PartyBalanceAdd(infoPartyBalance);
             }
             Messages.SavedMessage();
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.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);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Function to edit the service voucher
 /// </summary>
 /// <param name="decServiceMasterId"></param>
 public void EditFunction(decimal decServiceMasterId)
 {
     try
     {
         ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo();
         ServiceMasterSP spServiceMaster = new ServiceMasterSP();
         ServiceDetailsInfo infoServiceDetails = new ServiceDetailsInfo();
         ServiceDetailsSP spServiceDetails = new ServiceDetailsSP();
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
         ExchangeRateSP spExchangeRate = new ExchangeRateSP();
         int inRowCount = dgvServiceVoucher.RowCount;
         int inValue = 0;
         decimal decLedgerPostingId1 = 0;
         decimal decLedgerPostingId2 = 0;
         DataTable dtblLedgerPostingId = new DataTable();
         dtblLedgerPostingId = spServiceMaster.LedgerPostingIdByServiceMaasterId(decServiceMasterId);
         decLedgerPostingId1 = Convert.ToDecimal(dtblLedgerPostingId.Rows[0]["ledgerPostingId"].ToString());
         decLedgerPostingId2 = Convert.ToDecimal(dtblLedgerPostingId.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----------------------------------------//
             BankReconciliationSP spBankReconciliation = new BankReconciliationSP();
             foreach (object obj in strArrOfRemove)
             {
                 string str = Convert.ToString(obj);
                 spServiceDetails.ServiceDetailsDelete(Convert.ToDecimal(str));
             }
             spServiceMaster.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());
                         spServiceDetails.ServiceDetailsEdit(infoServiceDetails);
                     }
                     else
                     {
                         infoServiceDetails.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                         decServiceDetailsId = spServiceDetails.ServiceDetailsAddReturnWithIdentity(infoServiceDetails);
                     }
                     decSelectedCurrencyRate = spExchangeRate.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);
             AccountLedgerSP spAccountLedger = new AccountLedgerSP();
             decimal decI = Convert.ToDecimal(spAccountLedger.AccountGroupIdCheck(cmbCashParty.Text));
             if (decI > 0)
             {
                 PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
                 PartyBalanceSP spPartyBalance = new PartyBalanceSP();
                 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;
                 spPartyBalance.PartyBalanceEdit(infoPartyBalance);
             }
             Messages.UpdatedMessage();
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.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);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Function to get particular values from ServiceDetails Table based on the parameter
 /// </summary>
 /// <param name="serviceDetailsId"></param>
 /// <returns></returns>
 public ServiceDetailsInfo ServiceDetailsView(decimal serviceDetailsId)
 {
     ServiceDetailsInfo servicedetailsinfo = new ServiceDetailsInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceDetailsView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceDetailsId", SqlDbType.Decimal);
         sprmparam.Value = serviceDetailsId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             servicedetailsinfo.ServiceDetailsId = decimal.Parse(sdrreader[0].ToString());
             servicedetailsinfo.ServiceMasterId = decimal.Parse(sdrreader[1].ToString());
             servicedetailsinfo.ServiceId = decimal.Parse(sdrreader[2].ToString());
             servicedetailsinfo.Measure = sdrreader[3].ToString();
             servicedetailsinfo.Amount = decimal.Parse(sdrreader[4].ToString());
             servicedetailsinfo.ExtraDate = DateTime.Parse(sdrreader[5].ToString());
             servicedetailsinfo.Extra1 = sdrreader[6].ToString();
             servicedetailsinfo.Extra2 = sdrreader[7].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return servicedetailsinfo;
 }