Example #1
0
        /// <summary>
        /// Function to insert values to ContraMaster Table
        /// </summary>
        /// <param name="contramasterinfo"></param>
        /// <returns></returns>
        public decimal ContraMasterAdd(ContraMasterInfo contramasterinfo)
        {
            decimal decIdentity = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ContraMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.VoucherNo;
                sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.InvoiceNo;
                sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.SuffixPrefixId;
                sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = contramasterinfo.Date;
                sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.LedgerId;
                sprmparam       = sccmd.Parameters.Add("@type", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.Type;
                sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.TotalAmount;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.UserId;
                sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.VoucherTypeId;
                //sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                //sprmparam.Value = contramasterinfo.ExchangeRateId;
                sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = contramasterinfo.FinancialYearId;
                //sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                //sprmparam.Value = contramasterinfo.ExtraDate;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = contramasterinfo.Extra2;
                decIdentity     = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decIdentity);
        }
Example #2
0
 /// <summary>
 /// Function to insert values to ContraMaster Table
 /// </summary>
 /// <param name="contramasterinfo"></param>
 /// <returns></returns>
 public decimal ContraMasterAdd(ContraMasterInfo contramasterinfo)
 {
     decimal decIdentity = 0;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ContraMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.VoucherNo;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = contramasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Type;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.VoucherTypeId;
         //sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         //sprmparam.Value = contramasterinfo.ExchangeRateId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.FinancialYearId;
         //sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         //sprmparam.Value = contramasterinfo.ExtraDate;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra2;
         decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
     return decIdentity;
 }
Example #3
0
 /// <summary>
 /// Function to Update values in ContraMaster Table
 /// </summary>
 /// <param name="contramasterinfo"></param>
 public void ContraMasterEdit(ContraMasterInfo contramasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ContraMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.ContraMasterId;
         sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.InvoiceNo;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = contramasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@type", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Type;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.UserId;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.FinancialYearId;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #4
0
        /// <summary>
        /// Function to get particular values from ContraMaster table based on the parameter
        /// </summary>
        /// <param name="contraMasterId"></param>
        /// <returns></returns>
        public ContraMasterInfo ContraMasterView(decimal contraMasterId)
        {
            ContraMasterInfo contramasterinfo = new ContraMasterInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ContraMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
                sprmparam.Value = contraMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    contramasterinfo.ContraMasterId  = decimal.Parse(sdrreader[0].ToString());
                    contramasterinfo.VoucherNo       = sdrreader[1].ToString();
                    contramasterinfo.InvoiceNo       = sdrreader[2].ToString();
                    contramasterinfo.SuffixPrefixId  = decimal.Parse(sdrreader[3].ToString());
                    contramasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    contramasterinfo.LedgerId        = decimal.Parse(sdrreader[5].ToString());
                    contramasterinfo.Type            = sdrreader[6].ToString();
                    contramasterinfo.TotalAmount     = decimal.Parse(sdrreader[7].ToString());
                    contramasterinfo.Narration       = sdrreader[8].ToString();
                    contramasterinfo.UserId          = decimal.Parse(sdrreader[9].ToString());
                    contramasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[10].ToString());
                    contramasterinfo.FinancialYearId = decimal.Parse(sdrreader[11].ToString());
                    contramasterinfo.ExtraDate       = DateTime.Parse(sdrreader[12].ToString());
                    contramasterinfo.Extra1          = sdrreader[13].ToString();
                    contramasterinfo.Extra2          = sdrreader[14].ToString();
                    contramasterinfo.date            = sdrreader["date"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(contramasterinfo);
        }
Example #5
0
 /// <summary>
 /// Function to Update values in ContraMaster Table
 /// </summary>
 /// <param name="contramasterinfo"></param>
 public void ContraMasterEdit(ContraMasterInfo contramasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ContraMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.ContraMasterId;
         sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.InvoiceNo;
         sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.SuffixPrefixId;
         sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = contramasterinfo.Date;
         sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.LedgerId;
         sprmparam = sccmd.Parameters.Add("@type", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Type;
         sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.TotalAmount;
         sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Narration;
         sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.UserId;
         sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.VoucherTypeId;
         sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = contramasterinfo.FinancialYearId;
         sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra1;
         sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = contramasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Example #6
0
 /// <summary>
 /// Function to get particular values from ContraMaster table based on the parameter
 /// </summary>
 /// <param name="contraMasterId"></param>
 /// <returns></returns>
 public ContraMasterInfo ContraMasterView(decimal contraMasterId)
 {
     ContraMasterInfo contramasterinfo = new ContraMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ContraMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@contraMasterId", SqlDbType.Decimal);
         sprmparam.Value = contraMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             contramasterinfo.ContraMasterId = decimal.Parse(sdrreader[0].ToString());
             contramasterinfo.VoucherNo = sdrreader[1].ToString();
             contramasterinfo.InvoiceNo = sdrreader[2].ToString();
             contramasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[3].ToString());
             contramasterinfo.Date = DateTime.Parse(sdrreader[4].ToString());
             contramasterinfo.LedgerId = decimal.Parse(sdrreader[5].ToString());
             contramasterinfo.Type = sdrreader[6].ToString();
             contramasterinfo.TotalAmount = decimal.Parse(sdrreader[7].ToString());
             contramasterinfo.Narration = sdrreader[8].ToString();
             contramasterinfo.UserId = decimal.Parse(sdrreader[9].ToString());
             contramasterinfo.VoucherTypeId = decimal.Parse(sdrreader[10].ToString());
             contramasterinfo.FinancialYearId = decimal.Parse(sdrreader[11].ToString());
             contramasterinfo.ExtraDate = DateTime.Parse(sdrreader[12].ToString());
             contramasterinfo.Extra1 = sdrreader[13].ToString();
             contramasterinfo.Extra2 = sdrreader[14].ToString();
             contramasterinfo.date = sdrreader["date"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return contramasterinfo;
 }
Example #7
0
 /// <summary>
 /// Edit function Call the ledger posting Edit function also
 /// </summary>
 /// <param name="decMasterId"></param>
 public void EditFunction(decimal decMasterId)
 {
     try
     {
         ContraMasterSP spContraMaster = new ContraMasterSP();
         ContraMasterInfo infoContraMaster = new ContraMasterInfo();
         ContraDetailsSP spContraDetails = new ContraDetailsSP();
         ContraDetailsInfo infoCOntraDetails = new ContraDetailsInfo();
         ExchangeRateSP spExchangeRate = new ExchangeRateSP();
         LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
         decimal decContraDetailsId = 0;
         decimal decLedgerPostId = 0;
         infoContraMaster.ContraMasterId = decMasterId;
         infoContraMaster.LedgerId = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());
         if (isAutomatic)
         {
             infoContraMaster.VoucherNo = strVoucherNo;
         }
         if (isAutomatic)
         {
             infoContraMaster.InvoiceNo = strInvoiceNo;
         }
         else
         {
             infoContraMaster.InvoiceNo = txtVoucherNo.Text;
         }
         infoContraMaster.Date = Convert.ToDateTime(dtpContraVoucherDate.Text.ToString());
         infoContraMaster.Narration = txtNarration.Text.Trim();
         infoContraMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
         if (rbtnDeposit.Checked)
             infoContraMaster.Type = "Deposit";
         else
             infoContraMaster.Type = "Withdraw";
         infoContraMaster.SuffixPrefixId = decContraSuffixPrefixId;
         infoContraMaster.VoucherTypeId = DecContraVoucherTypeId;
         infoContraMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoContraMaster.UserId = PublicVariables._decCurrentUserId;
         infoContraMaster.Extra1 = string.Empty;
         infoContraMaster.Extra2 = string.Empty;
         infoContraMaster.Date = Convert.ToDateTime(txtContraVoucherDate.Text);
         int inCount = dgvContraVoucher.RowCount;
         int inValue = 0;
         for (int i = 0; i < inCount - 1; i++)
         {
             if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null &&
                 dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != null)
             {
                 inValue++;
             }
         }
         if (inValue > 0)
         {
             if (Convert.ToDecimal(txtTotal.Text) != 0)
             {
                 infoCOntraDetails.ContraMasterId = decMasterId;
                 infoCOntraDetails.Extra1 = string.Empty;
                 infoCOntraDetails.Extra2 = string.Empty;
                 //------------------deleting removed rows----------------------------------------//
                 foreach (var item in arrlstOfRemove)
                 {
                     decimal decId = Convert.ToDecimal(item);
                     spContraDetails.ContraDetailsDelete(Convert.ToDecimal(decId));
                     spLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(decId), strVoucherNo, DecContraVoucherTypeId);
                 }
                 //--------------------------End---------------------------------------------------//
                 int inRowCount = dgvContraVoucher.RowCount;
                 decimal decLedgerId = 0;
                 decimal decLedger1Id = 0;
                 decimal decDebit = 0;
                 decimal decCredit = 0;
                 decLedger1Id = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());
                 for (int i = 0; i < inRowCount; i++)
                 {
                     if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "")
                     {
                         decLedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                         infoCOntraDetails.LedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString() != "")
                     {
                         infoCOntraDetails.ChequeNo = dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString();
                     }
                     else
                     {
                         infoCOntraDetails.ChequeNo = string.Empty;
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString() != "")
                     {
                         infoCOntraDetails.ChequeDate = Convert.ToDateTime(dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString());
                     }
                     else
                     {
                         infoCOntraDetails.ChequeDate = Convert.ToDateTime("1/1/1753");
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != "")
                     {
                         infoCOntraDetails.Amount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                         if (dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString() != "")
                         {
                             infoCOntraDetails.ContraDetailsId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value.ToString());
                             decContraDetailsId = infoCOntraDetails.ContraDetailsId;
                             decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString()));
                             decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                             decConvertRate = decAmount * decSelectedCurrencyRate;
                             if (rbtnDeposit.Checked)
                             {
                                 decCredit = decConvertRate;
                                 decDebit = 0;
                             }
                             else
                             {
                                 decDebit = decConvertRate;
                                 decCredit = 0;
                             }
                             infoCOntraDetails.ContraMasterId = decMasterId;
                             infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                             spContraDetails.ContraDetailsEdit(infoCOntraDetails);
                             decLedgerPostId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                             LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                         }
                         else
                         {
                             infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                             decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString()));
                             decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                             decConvertRate = decAmount * decSelectedCurrencyRate;
                             if (rbtnDeposit.Checked)
                             {
                                 decCredit = decConvertRate;
                                 decDebit = 0;
                             }
                             else
                             {
                                 decDebit = decConvertRate;
                                 decCredit = 0;
                             }
                             decContraDetailsId = spContraDetails.ContraDetailsAddReturnWithhIdentity(infoCOntraDetails);
                             LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                         }
                     }
                 }
                 spContraMaster.ContraMasterEdit(infoContraMaster);
                 decLedgerPostId = spLedgerPosting.LedgerPostingIdForTotalAmount(strVoucherNo, DecContraVoucherTypeId);
                 decAmount = Convert.ToDecimal(txtTotal.Text);
                 decContraDetailsId = 0;
                 if (rbtnDeposit.Checked)
                 {
                     decDebit = decAmount;
                     decCredit = 0;
                     LedgerPostingEdit(decLedgerPostId, decLedger1Id, decCredit, decDebit, decContraDetailsId, -1);
                 }
                 else
                 {
                     decCredit = decAmount;
                     decDebit = 0;
                     LedgerPostingEdit(decLedgerPostId, decLedger1Id, decCredit, decDebit, decContraDetailsId, -1);
                 }
                 Messages.UpdatedMessage();
                 if (cbxPrintafterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decMasterId);
                     }
                     else
                     {
                         Print(decMasterId);
                     }
                 }
                 this.Close();
             }
             else
             {
                 Messages.InformationMessage("Cannot save total amount as 0");
                 dgvContraVoucher.Focus();
             }
         }
         else
         {
             Messages.InformationMessage("Cant update contra voucher without atleast one ledger with complete details");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:17" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #8
0
 /// <summary>
 /// Save function Call the ledger posting function also
 /// </summary>
 public void SaveFuction()
 {
     try
     {
         decimal decContraDetailsId = 0;
         ContraMasterSP spContraMaster = new ContraMasterSP();
         ContraMasterInfo infoContraMaster = new ContraMasterInfo();
         ContraDetailsSP spContraDetails = new ContraDetailsSP();
         ContraDetailsInfo infoCOntraDetails = new ContraDetailsInfo();
         ExchangeRateSP spExchangeRate = new ExchangeRateSP();
         decimal decIdentity = 0;
         decimal decLedgerId = 0;
         decimal decDebit = 0;
         decimal decCredit = 0;
         int inCount = dgvContraVoucher.RowCount;
         int inValue = 0;
         for (int i = 0; i < inCount - 1; i++)
         {
             if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null &&
                 dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != null)
             {
                 inValue++;
             }
         }
         if (inValue > 0)
         {
             if (Convert.ToDecimal(txtTotal.Text) != 0)
             {
                 infoContraMaster.LedgerId = Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString());
                 if (isAutomatic)
                 {
                     infoContraMaster.VoucherNo = strVoucherNo;
                 }
                 else
                 {
                     decimal decVoucherNo = spContraMaster.ContraVoucherMasterGetMaxPlusOne(DecContraVoucherTypeId) + 1;
                     infoContraMaster.VoucherNo = Convert.ToString(decVoucherNo);
                 }
                 infoContraMaster.Date = Convert.ToDateTime(dtpContraVoucherDate.Text.ToString());
                 infoContraMaster.Narration = txtNarration.Text.Trim();
                 infoContraMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
                 infoContraMaster.Extra1 = string.Empty;
                 infoContraMaster.Extra2 = string.Empty;
                 if (rbtnDeposit.Checked)
                 {
                     infoContraMaster.Type = "Deposit";
                 }
                 else
                 {
                     infoContraMaster.Type = "Withdraw";
                 }
                 infoContraMaster.SuffixPrefixId = decContraSuffixPrefixId;
                 infoContraMaster.VoucherTypeId = DecContraVoucherTypeId;
                 infoContraMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                 infoContraMaster.UserId = PublicVariables._decCurrentUserId;
                 if (isAutomatic)
                 {
                     infoContraMaster.InvoiceNo = strInvoiceNo;
                 }
                 else
                 {
                     infoContraMaster.InvoiceNo = txtVoucherNo.Text;
                 }
                 decIdentity = spContraMaster.ContraMasterAdd(infoContraMaster);
                 infoCOntraDetails.ContraMasterId = decIdentity;
                 infoCOntraDetails.Extra1 = string.Empty;
                 infoCOntraDetails.Extra2 = string.Empty;
                 int inRowCount = dgvContraVoucher.RowCount;
                 //-------------------------------Saving grid details--------------------------------------------------------------------
                 for (int i = 0; i < inRowCount - 1; i++)
                 {
                     if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != string.Empty)
                     {
                         infoCOntraDetails.LedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                     {
                         infoCOntraDetails.Amount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                     {
                         infoCOntraDetails.ChequeNo = dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value.ToString();
                     }
                     else
                     {
                         infoCOntraDetails.ChequeNo = string.Empty;
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                     {
                         infoCOntraDetails.ChequeDate = Convert.ToDateTime(dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value.ToString());
                     }
                     else
                     {
                         infoCOntraDetails.ChequeDate = Convert.ToDateTime("1/1/1753");
                     }
                     infoCOntraDetails.ExchangeRateId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value.ToString());
                     decContraDetailsId = spContraDetails.ContraDetailsAddReturnWithhIdentity(infoCOntraDetails);
                     //---------------------------------------------------------Ledger Posting-----------------------------------------/---------------------------------------------------/
                     if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != string.Empty)
                     {
                         decLedgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString());
                     }
                     if (dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                     {
                         decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value));
                         decAmount = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString());
                         decConvertRate = decAmount * decSelectedCurrencyRate;
                         if (rbtnDeposit.Checked)
                         {
                             decCredit = decConvertRate;
                             decDebit = 0;
                             LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                         }
                         else
                         {
                             decDebit = decConvertRate;
                             decCredit = 0;
                             LedgerPosting(decLedgerId, decCredit, decDebit, decContraDetailsId, i);
                         }
                     }
                 }
                 decAmount = Convert.ToDecimal(txtTotal.Text);
                 decContraDetailsId = 0;
                 if (rbtnDeposit.Checked)
                 {
                     decDebit = decAmount;
                     decCredit = 0;
                     LedgerPosting(infoContraMaster.LedgerId, decCredit, decDebit, decContraDetailsId, -1);
                 }
                 else
                 {
                     decCredit = decAmount;
                     decDebit = 0;
                     LedgerPosting(infoContraMaster.LedgerId, decCredit, decDebit, decContraDetailsId, -1);
                 }
                 //------------------------------------------------------------------Ledger Posting---end---------------------------------------------------------------------//
                 Messages.SavedMessage();
                 if (cbxPrintafterSave.Checked)
                 {
                     if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decIdentity);
                     }
                     else
                     {
                         Print(decIdentity);
                     }
                 }
                 Clear();
             }
             else
             {
                 Messages.InformationMessage("Cannot save total debit and credit as 0");
                 dgvContraVoucher.Focus();
             }
         }
         else
         {
             Messages.InformationMessage("Cant save contra voucher without atleast one ledger with complete details");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:16" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #9
0
 /// <summary>
 /// Fill all the controlls while coming from other forms for update or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         ContraDetailsSP spContraDetails = new ContraDetailsSP();
         ContraMasterSP spContraMaster = new ContraMasterSP();
         ContraMasterInfo infoContraMaster = new ContraMasterInfo();
         LedgerPostingSP SpLedgerPosting = new LedgerPostingSP();
         VoucherTypeSP spVoucherType = new VoucherTypeSP();
         infoContraMaster = spContraMaster.ContraMasterView(decMasterId);
         txtVoucherNo.ReadOnly = false;
         strVoucherNo = infoContraMaster.VoucherNo;
         txtVoucherNo.Text = infoContraMaster.InvoiceNo;
         strInvoiceNo = infoContraMaster.InvoiceNo;
         strInvoiceNo = infoContraMaster.InvoiceNo;
         decContraSuffixPrefixId = Convert.ToDecimal(infoContraMaster.SuffixPrefixId.ToString());
         DecContraVoucherTypeId = Convert.ToDecimal(infoContraMaster.VoucherTypeId.ToString());
         int inDecimalPlace = PublicVariables._inNoOfDecimalPlaces;
         txtNarration.Text = infoContraMaster.Narration;
         txtContraVoucherDate.Text = Convert.ToString(infoContraMaster.date);
         cmbBankAccount.SelectedValue = infoContraMaster.LedgerId;
         strVoucherNo = infoContraMaster.VoucherNo;
         if (infoContraMaster.Type == "Deposit")
         {
             rbtnDeposit.Checked = true;
         }
         else
         {
             rbtnWithdrawal.Checked = true;
         }
         isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(DecContraVoucherTypeId);
         if (isAutomatic)
         {
             txtVoucherNo.Enabled = false;
         }
         else
         {
             txtVoucherNo.Enabled = true;
         }
         DataTable dtbl = new DataTable();
         dtbl = spContraDetails.ContraDetailsViewWithMasterId(decMasterId);
         for (int i = 0; i < dtbl.Rows.Count; i++)
         {
             dgvContraVoucher.Rows.Add();
             dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value = Convert.ToDecimal(dtbl.Rows[i]["ledgerId"].ToString());
             dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[i]["exchangeRateId"].ToString());
             dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[i]["amount"].ToString());
             if (dtbl.Rows[i]["chequeNo"].ToString() != string.Empty)
             {
                 dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[i]["chequeNo"].ToString();
                 if (dtbl.Rows[i]["chequeDate"].ToString() == "01 Jan 1753")
                 {
                     dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value = null;
                 }
                 else
                 {
                     dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value = dtbl.Rows[i]["chequeDate"].ToString();
                 }
             }
             dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value = dtbl.Rows[i]["contraDetailsId"].ToString();
             decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[i]["contraDetailsId"].ToString());
             decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, DecContraVoucherTypeId);
             dgvContraVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:31" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }