Ejemplo n.º 1
0
        /// <summary>
        /// Function to get values for Service VoucherTypeId By ServiceMasterId And VocherNo
        /// </summary>
        /// <param name="decServiceMasterId"></param>
        /// <param name="decVoucherNo"></param>
        /// <returns></returns>
        public ServiceMasterInfo GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo(decimal decServiceMasterId, decimal decVoucherNo)
        {
            ServiceMasterInfo servicemasterinfo = new ServiceMasterInfo();
            SqlDataReader     sdrreader         = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
                sprmparam.Value = decServiceMasterId;
                sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.Decimal);
                sprmparam.Value = decVoucherNo;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    servicemasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(servicemasterinfo);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Function to Update values in ServiceMaster Table
 /// </summary>
 /// <param name="servicemasterinfo"></param>
 public void ServiceMasterEdit(ServiceMasterInfo servicemasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ServiceMasterId;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = servicemasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.UserId;
         sprmparam       = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int);
         sprmparam.Value = servicemasterinfo.CreditPeriod;
         sprmparam       = sccmd.Parameters.Add("@serviceAccount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ServiceAccount;
         sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ExchangeRateId;
         sprmparam       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.EmployeeId;
         sprmparam       = sccmd.Parameters.Add("@customer", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Customer;
         sprmparam       = sccmd.Parameters.Add("@discount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.Discount;
         sprmparam       = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.GrandTotal;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.FinancialYearId;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicemasterinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Ejemplo n.º 3
0
        /// <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();
            SqlDataReader     sdrreader         = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
                sprmparam.Value = serviceMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    servicemasterinfo.ServiceMasterId = decimal.Parse(sdrreader["serviceMasterId"].ToString());
                    servicemasterinfo.VoucherNo       = sdrreader["voucherNo"].ToString();
                    servicemasterinfo.InvoiceNo       = sdrreader["invoiceNo"].ToString();
                    servicemasterinfo.SuffixPrefixId  = decimal.Parse(sdrreader["suffixPrefixId"].ToString());
                    servicemasterinfo.Date            = DateTime.Parse(sdrreader["date"].ToString());
                    servicemasterinfo.LedgerId        = decimal.Parse(sdrreader["ledgerId"].ToString());
                    servicemasterinfo.TotalAmount     = decimal.Parse(sdrreader["totalAmount"].ToString());
                    servicemasterinfo.Narration       = sdrreader["narration"].ToString();
                    servicemasterinfo.UserId          = decimal.Parse(sdrreader["userId"].ToString());
                    servicemasterinfo.CreditPeriod    = int.Parse(sdrreader["creditPeriod"].ToString());
                    servicemasterinfo.ServiceAccount  = decimal.Parse(sdrreader["serviceAccount"].ToString());
                    servicemasterinfo.ExchangeRateId  = decimal.Parse(sdrreader["exchangeRateId"].ToString());
                    servicemasterinfo.EmployeeId      = Convert.ToDecimal(sdrreader["employeeId"].ToString());
                    servicemasterinfo.Customer        = sdrreader["customer"].ToString();
                    servicemasterinfo.Discount        = decimal.Parse(sdrreader["discount"].ToString());
                    servicemasterinfo.GrandTotal      = decimal.Parse(sdrreader["grandTotal"].ToString());
                    servicemasterinfo.VoucherTypeId   = decimal.Parse(sdrreader["voucherTypeId"].ToString());
                    servicemasterinfo.FinancialYearId = decimal.Parse(sdrreader["financialYearId"].ToString());
                    servicemasterinfo.ExtraDate       = DateTime.Parse(sdrreader["extraDate"].ToString());
                    servicemasterinfo.Extra1          = sdrreader["extra1"].ToString();
                    servicemasterinfo.Extra2          = sdrreader["extra2"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(servicemasterinfo);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Function to get values for Service VoucherTypeId By ServiceMasterId And VocherNo 
 /// </summary>
 /// <param name="decServiceMasterId"></param>
 /// <param name="decVoucherNo"></param>
 /// <returns></returns>
 public ServiceMasterInfo GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo(decimal decServiceMasterId, decimal decVoucherNo)
 {
     ServiceMasterInfo servicemasterinfo = new ServiceMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("GetServiceVoucherTypeIdByServiceMasterIdAndVocherNo", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = decServiceMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.Decimal);
         sprmparam.Value = decVoucherNo;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             servicemasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return servicemasterinfo;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Function to insert values to ServiceMaster Table
 /// </summary>
 /// <param name="servicemasterinfo"></param>
 /// <returns></returns>
 public decimal ServiceMasterAdd(ServiceMasterInfo servicemasterinfo)
 {
     decimal decIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ServiceMasterId;
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = servicemasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int);
         sprmparam.Value = servicemasterinfo.CreditPeriod;
         sprmparam = sccmd.Parameters.Add("@serviceAccount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ServiceAccount;
         sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.EmployeeId;
         sprmparam = sccmd.Parameters.Add("@customer", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Customer;
         sprmparam = sccmd.Parameters.Add("@discount", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.Discount;
         sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.GrandTotal;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = servicemasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = servicemasterinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicemasterinfo.Extra2;
         decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decIdentity;
 }
Ejemplo n.º 6
0
 /// <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();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@serviceMasterId", SqlDbType.Decimal);
         sprmparam.Value = serviceMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             servicemasterinfo.ServiceMasterId = decimal.Parse(sdrreader["serviceMasterId"].ToString());
             servicemasterinfo.VoucherNo = sdrreader["voucherNo"].ToString();
             servicemasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString();
             servicemasterinfo.SuffixPrefixId = decimal.Parse(sdrreader["suffixPrefixId"].ToString());
             servicemasterinfo.Date = DateTime.Parse(sdrreader["date"].ToString());
             servicemasterinfo.LedgerId = decimal.Parse(sdrreader["ledgerId"].ToString());
             servicemasterinfo.TotalAmount = decimal.Parse(sdrreader["totalAmount"].ToString());
             servicemasterinfo.Narration = sdrreader["narration"].ToString();
             servicemasterinfo.UserId = decimal.Parse(sdrreader["userId"].ToString());
             servicemasterinfo.CreditPeriod = int.Parse(sdrreader["creditPeriod"].ToString());
             servicemasterinfo.ServiceAccount = decimal.Parse(sdrreader["serviceAccount"].ToString());
             servicemasterinfo.ExchangeRateId = decimal.Parse(sdrreader["exchangeRateId"].ToString());
             servicemasterinfo.EmployeeId = Convert.ToDecimal(sdrreader["employeeId"].ToString());
             servicemasterinfo.Customer = sdrreader["customer"].ToString();
             servicemasterinfo.Discount = decimal.Parse(sdrreader["discount"].ToString());
             servicemasterinfo.GrandTotal = decimal.Parse(sdrreader["grandTotal"].ToString());
             servicemasterinfo.VoucherTypeId = decimal.Parse(sdrreader["voucherTypeId"].ToString());
             servicemasterinfo.FinancialYearId = decimal.Parse(sdrreader["financialYearId"].ToString());
             servicemasterinfo.ExtraDate = DateTime.Parse(sdrreader["extraDate"].ToString());
             servicemasterinfo.Extra1 = sdrreader["extra1"].ToString();
             servicemasterinfo.Extra2 = sdrreader["extra2"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return servicemasterinfo;
 }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Function to fill the fields for edit or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         ServiceDetailsSP spServiceDetails = new ServiceDetailsSP();
         ServiceMasterSP spServiceMaster = new ServiceMasterSP();
         ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo();
         LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
         VoucherTypeSP spVoucherType = new VoucherTypeSP();
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         PartyBalanceSP spPartyBalance = new PartyBalanceSP();
         PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
         decServiceMasterId = decMasterId;
         infoServiceMaster = spServiceMaster.ServiceMasterView(decServiceMasterId);
         infoVoucherType = spVoucherType.VoucherTypeView(infoServiceMaster.VoucherTypeId);
         this.Text = infoVoucherType.VoucherTypeName;
         isAutomatic = spVoucherType.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;
         DataTable dtblServiceDetails = new DataTable();
         dtblServiceDetails = spServiceDetails.ServiceDetailsViewWithMasterId(decServiceMasterId);
         for (int i = 0; i < dtblServiceDetails.Rows.Count; i++)
         {
             dgvServiceVoucher.Rows.Add();
             dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value = Convert.ToDecimal(dtblServiceDetails.Rows[i]["serviceDetailsId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvtxtServiceMasterId"].Value = Convert.ToDecimal(dtblServiceDetails.Rows[i]["serviceMasterId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value = Convert.ToDecimal(dtblServiceDetails.Rows[i]["serviceId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value = dtblServiceDetails.Rows[i]["measure"].ToString();
             dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value = dtblServiceDetails.Rows[i]["amount"].ToString();
             decimal decDetailsId1 = Convert.ToDecimal(dtblServiceDetails.Rows[i]["serviceDetailsId"].ToString());
             decimal decLedgerPostingId = SpLedgerPosting.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 = spPartyBalance.PartyBalanceViewByVoucherNoAndVoucherTypeId(DecServicetVoucherTypeId, strVoucherNo, infoServiceMaster.Date);
         decPartyBalanceId = infoPartyBalance.PartyBalanceId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 32 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 9
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);
     }
 }