コード例 #1
0
        /// <summary>
        /// Function to Update values in account group Table
        /// </summary>
        /// <param name="creditnotemasterinfo"></param>
        /// <returns></returns>
        public decimal CreditNoteMasterEdit(CreditNoteMasterInfo creditnotemasterinfo)
        {
            decimal decCreditNoteMaster = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("CreditNoteMasterEdit", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam           = sccmd.Parameters.Add("@creditNoteMasterId", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.CreditNoteMasterId;
                sprmparam           = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value     = creditnotemasterinfo.VoucherNo;
                sprmparam           = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value     = creditnotemasterinfo.InvoiceNo;
                sprmparam           = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.SuffixPrefixId;
                sprmparam           = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value     = creditnotemasterinfo.Date;
                sprmparam           = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.UserId;
                sprmparam           = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.TotalAmount;
                sprmparam           = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value     = creditnotemasterinfo.Narration;
                sprmparam           = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.FinancialYearId;
                sprmparam           = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value     = creditnotemasterinfo.ExtraDate;
                sprmparam           = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value     = creditnotemasterinfo.Extra1;
                sprmparam           = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value     = creditnotemasterinfo.Extra2;
                sprmparam           = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value     = creditnotemasterinfo.VoucherTypeId;
                decCreditNoteMaster = sccmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decCreditNoteMaster);
        }
コード例 #2
0
        public decimal CreditNoteMasterAdd(CreditNoteMasterInfo creditnotemasterinfo)
        {
            decimal decId = 0;

            try
            {
                decId = SpCreditNoteMaster.CreditNoteMasterAdd(creditnotemasterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CNB:4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decId);
        }
コード例 #3
0
        public CreditNoteMasterInfo CreditNoteMasterView(decimal creditNoteMasterId)
        {
            CreditNoteMasterInfo InfoCreditNoteMaster = new CreditNoteMasterInfo();

            try
            {
                InfoCreditNoteMaster = SpCreditNoteMaster.CreditNoteMasterView(creditNoteMasterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("SB6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(InfoCreditNoteMaster);
        }
コード例 #4
0
        /// <summary>
        /// Function to get particular values from account CreditNoteMaster based on the parameter
        /// </summary>
        /// <param name="creditNoteMasterId"></param>
        /// <returns></returns>
        public CreditNoteMasterInfo CreditNoteMasterView(decimal creditNoteMasterId)
        {
            CreditNoteMasterInfo creditnotemasterinfo = new CreditNoteMasterInfo();

            try
            {
                creditnotemasterinfo = SpCreditNoteMaster.CreditNoteMasterView(creditNoteMasterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(creditnotemasterinfo);
        }
コード例 #5
0
        /// <summary>
        /// Function to Update values in account group Table
        /// </summary>
        /// <param name="creditnotemasterinfo"></param>
        /// <returns></returns>
        public decimal  CreditNoteMasterEdit(CreditNoteMasterInfo creditnotemasterinfo)
        {
            decimal decCreditNoteMaster = 0;

            try
            {
                decCreditNoteMaster = SpCreditNoteMaster.CreditNoteMasterEdit(creditnotemasterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decCreditNoteMaster);
        }
コード例 #6
0
        /// <summary>
        /// Function to insert values to account group Table
        /// </summary>
        /// <param name="creditnotemasterinfo"></param>
        /// <returns></returns>
        public decimal CreditNoteMasterAdd(CreditNoteMasterInfo creditnotemasterinfo)
        {
            decimal identity = 0;

            try
            {
                identity = SpCreditNoteMaster.CreditNoteMasterAdd(creditnotemasterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(identity);
        }
コード例 #7
0
        public decimal CreditNoteMasterAdd(CreditNoteMasterInfo creditnotemasterinfo)
        {
            decimal identity = 0m;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("CreditNoteMasterAdd", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam12 = new SqlParameter();
                sprmparam12       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam12.Value = creditnotemasterinfo.VoucherNo;
                sprmparam12       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam12.Value = creditnotemasterinfo.InvoiceNo;
                sprmparam12       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam12.Value = creditnotemasterinfo.SuffixPrefixId;
                sprmparam12       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam12.Value = creditnotemasterinfo.Date;
                sprmparam12       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam12.Value = creditnotemasterinfo.UserId;
                sprmparam12       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam12.Value = creditnotemasterinfo.TotalAmount;
                sprmparam12       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam12.Value = creditnotemasterinfo.Narration;
                sprmparam12       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam12.Value = creditnotemasterinfo.FinancialYearId;
                sprmparam12       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam12.Value = creditnotemasterinfo.Extra1;
                sprmparam12       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam12.Value = creditnotemasterinfo.Extra2;
                sprmparam12       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam12.Value = creditnotemasterinfo.VoucherTypeId;
                identity          = Convert.ToDecimal(sccmd.ExecuteScalar().ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                base.sqlcon.Close();
            }
            return(identity);
        }
コード例 #8
0
        /// <summary>
        /// Function to get particular values from account CreditNoteMaster based on the parameter
        /// </summary>
        /// <param name="creditNoteMasterId"></param>
        /// <returns></returns>
        public CreditNoteMasterInfo CreditNoteMasterView(decimal creditNoteMasterId)
        {
            CreditNoteMasterInfo creditnotemasterinfo = new CreditNoteMasterInfo();
            SqlDataReader        sdrreader            = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("CreditNoteMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@creditNoteMasterId", SqlDbType.Decimal);
                sprmparam.Value = creditNoteMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    creditnotemasterinfo.CreditNoteMasterId = decimal.Parse(sdrreader[0].ToString());
                    creditnotemasterinfo.VoucherNo          = sdrreader[1].ToString();
                    creditnotemasterinfo.InvoiceNo          = sdrreader[2].ToString();
                    creditnotemasterinfo.SuffixPrefixId     = decimal.Parse(sdrreader[3].ToString());
                    creditnotemasterinfo.Date            = DateTime.Parse(sdrreader[4].ToString());
                    creditnotemasterinfo.VoucherTypeId   = decimal.Parse(sdrreader[5].ToString());
                    creditnotemasterinfo.UserId          = decimal.Parse(sdrreader[6].ToString());
                    creditnotemasterinfo.TotalAmount     = decimal.Parse(sdrreader[7].ToString());
                    creditnotemasterinfo.Narration       = sdrreader[8].ToString();
                    creditnotemasterinfo.FinancialYearId = decimal.Parse(sdrreader[9].ToString());
                    creditnotemasterinfo.ExtraDate       = DateTime.Parse(sdrreader[10].ToString());
                    creditnotemasterinfo.Extra1          = sdrreader[11].ToString();
                    creditnotemasterinfo.Extra2          = sdrreader[12].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(creditnotemasterinfo);
        }
コード例 #9
0
        /// <summary>
        /// Function to edit the voucher
        /// </summary>
        /// <param name="decCreditNoteMasterId"></param>
        public void Edit(decimal decCreditNoteMasterId)
        {
            try
            {
                CreditNoteBll BllCreditnoteMaster = new CreditNoteBll();
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteBll BllCreditNoteDetails = new CreditNoteBll();
                CreditNoteDetailsInfo infoCreditNoteDetails = new CreditNoteDetailsInfo();
                ExchangeRateBll BllExchangeRate = new ExchangeRateBll();

                /*****************Update in CreditNoteMaster table *************/
                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                infoCreditNoteMaster.CreditNoteMasterId = decCreditNoteMasterId;
                infoCreditNoteMaster.VoucherNo = strVoucherNo;
                infoCreditNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoCreditNoteMaster.SuffixPrefixId = decCreditNoteSuffixPrefixId;
                infoCreditNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoCreditNoteMaster.Narration = txtNarration.Text.Trim();
                infoCreditNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoCreditNoteMaster.VoucherTypeId = decCreditNoteVoucherTypeId;
                infoCreditNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoCreditNoteMaster.ExtraDate = DateTime.Now;
                infoCreditNoteMaster.Extra1 = string.Empty;
                infoCreditNoteMaster.Extra2 = string.Empty;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());

                infoCreditNoteMaster.TotalAmount = decTotalDebit;
                decimal decEffectRow = BllCreditnoteMaster.CreditNoteMasterEdit(infoCreditNoteMaster);

                /**********************CreditNote Details Edit********************/
                if (decEffectRow > 0)
                {
                    infoCreditNoteDetails.CreditNoteMasterId = decCreditNoteMasterId;
                    infoCreditNoteDetails.ExtraDate = DateTime.Now;
                    infoCreditNoteDetails.Extra1 = string.Empty;
                    infoCreditNoteDetails.Extra2 = string.Empty;

                    //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------//
                    LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                    foreach (object obj in arrlstOfRemove)
                    {
                        string str = Convert.ToString(obj);
                        BllCreditNoteDetails.CreditNoteDetailsDelete(Convert.ToDecimal(str));
                        BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decCreditNoteVoucherTypeId);
                    }
                    BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decCreditNoteVoucherTypeId, 12);
                    //=============================================================================================//

                    decimal decLedgerId = 0;
                    decimal decDebit = 0;
                    decimal decCredit = 0;
                    decimal decCreditNoteDetailsId = 0;
                    int inRowCount = dgvCreditNote.RowCount;
                    for (int inI = 0; inI < inRowCount; inI++)
                    {
                        if (dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            infoCreditNoteDetails.LedgerId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                            decLedgerId = infoCreditNoteDetails.LedgerId;
                        }
                        if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                        {
                            //------------------Currency conversion------------------//
                            decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value));
                            decAmount = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //======================================================//

                            if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoCreditNoteDetails.Debit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Credit = 0;

                                decDebit = decConvertRate;
                                decCredit = infoCreditNoteDetails.Credit;
                            }
                            else
                            {
                                infoCreditNoteDetails.Credit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Debit = 0;
                                decDebit = infoCreditNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                            infoCreditNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeNo = dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeNo = string.Empty;
                            }
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeDate = DateTime.Now;
                            }
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.CreditNoteDetailsId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString());
                                BllCreditNoteDetails.CreditNoteDetailsEdit(infoCreditNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                decCreditNoteDetailsId = infoCreditNoteDetails.CreditNoteDetailsId;
                                decimal decLedgerPostId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                                LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decCreditNoteDetailsId, inI);

                            }
                            else
                            {
                                decCreditNoteDetailsId = BllCreditNoteDetails.CreditNoteDetailsAdd(infoCreditNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                LedgerPosting(decLedgerId, decCredit, decDebit, decCreditNoteDetailsId, inI);
                            }

                        }

                    }
                    DeletePartyBalanceOfRemovedRow();
                    Messages.UpdatedMessage();

                }
                //----------------If print after save is enable-----------------------//
                SettingsBll BllSettings = new SettingsBll();
                if (cbxPrintAfterSave.Checked)
                {
                    if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(infoCreditNoteMaster.CreditNoteMasterId);
                    }
                    else
                    {
                        Print(infoCreditNoteMaster.CreditNoteMasterId);
                    }
                }

                //===================================================================//
                if (CreditNoteRegisterObj != null)
                {
                    this.Close();
                    CreditNoteRegisterObj.Enabled = true;

                }
                else if (frmCreditNoteReportObj != null)
                {
                    this.Close();
                    frmCreditNoteReportObj.Enabled = true;

                }
                else
                {
                    clear();
                }
                if (frmBillallocationObj != null)
                {
                    this.Close();
                }
                if (frmDayBookObj != null)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:35" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #10
0
        /// <summary>
        /// Function to save the voucher
        /// </summary>
        public void Save()
        {
            try
            {
                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());

                CreditNoteBll BllCreditNoteMaster = new CreditNoteBll();
                CreditNoteBll BllCreditNoteDetails = new CreditNoteBll();
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteDetailsInfo infoCreditNoteDetails = new CreditNoteDetailsInfo();
                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                ExchangeRateBll BllExchangeRate = new ExchangeRateBll();

                infoCreditNoteMaster.VoucherNo = strVoucherNo;
                infoCreditNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoCreditNoteMaster.SuffixPrefixId = decCreditNoteSuffixPrefixId;
                infoCreditNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoCreditNoteMaster.Narration = txtNarration.Text.Trim();
                infoCreditNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoCreditNoteMaster.VoucherTypeId = decCreditNoteVoucherTypeId;
                infoCreditNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoCreditNoteMaster.Extra1 = string.Empty;
                infoCreditNoteMaster.Extra2 = string.Empty;

                infoCreditNoteMaster.TotalAmount = decTotalDebit;
                decimal decCreditNoteMasterId = BllCreditNoteMaster.CreditNoteMasterAdd(infoCreditNoteMaster);

                /*******************CreditNote Details Add and LedgerPosting*************************/
                infoCreditNoteDetails.CreditNoteMasterId = decCreditNoteMasterId;
                infoCreditNoteDetails.ExtraDate = DateTime.Now;
                infoCreditNoteDetails.Extra1 = string.Empty;
                infoCreditNoteDetails.Extra2 = string.Empty;

                decimal decLedgerId = 0;
                decimal decDebit = 0;
                decimal decCredit = 0;
                int inRowCount = dgvCreditNote.RowCount;
                for (int inI = 0; inI < inRowCount - 1; inI++)
                {
                    if (dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {
                        infoCreditNoteDetails.LedgerId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        decLedgerId = infoCreditNoteDetails.LedgerId;
                    }
                    if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                    {
                        if (dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                        {
                            //--------Currency conversion--------------//
                            decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()));
                            decAmount = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //===========================================//
                            if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoCreditNoteDetails.Debit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Credit = 0;
                                decDebit = decConvertRate;
                                decCredit = infoCreditNoteDetails.Credit;
                            }
                            else
                            {
                                infoCreditNoteDetails.Credit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Debit = 0;
                                decDebit = infoCreditNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                        }
                        infoCreditNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            infoCreditNoteDetails.ChequeNo = dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            infoCreditNoteDetails.ChequeNo = string.Empty;
                            infoCreditNoteDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decDetailsId = BllCreditNoteDetails.CreditNoteDetailsAdd(infoCreditNoteDetails);

                        if (decDetailsId != 0)
                        {
                            PartyBalanceAddOrEdit(inI);
                            LedgerPosting(decLedgerId, decCredit, decDebit, decDetailsId, inI);
                        }
                    }

                }

                Messages.SavedMessage();

                //----------------If print after save is enable-----------------------//
                SettingsBll BllSettings = new SettingsBll();
                if (cbxPrintAfterSave.Checked)
                {
                    if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decCreditNoteMasterId);
                    }
                    else
                    {
                        Print(decCreditNoteMasterId);
                    }
                }

                //===================================================================//
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:31" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #11
0
        /// <summary>
        /// Function to fill the controlls
        /// </summary>
        public void FillFunction()
        {
            try
            {
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteBll BllCreditNoteMaster = new CreditNoteBll();
                infoCreditNoteMaster = BllCreditNoteMaster.CreditNoteMasterView(decCreditNoteMasterIdForEdit);

                txtVoucherNo.ReadOnly = false;
                strVoucherNo = infoCreditNoteMaster.VoucherNo;
                strInvoiceNo = infoCreditNoteMaster.InvoiceNo;
                txtVoucherNo.Text = strInvoiceNo;
                decCreditNoteSuffixPrefixId = infoCreditNoteMaster.SuffixPrefixId;
                decCreditNoteVoucherTypeId = infoCreditNoteMaster.VoucherTypeId;
                dtpVoucherDate.Value = infoCreditNoteMaster.Date;

                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decCreditNoteVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                }

                txtNarration.Text = infoCreditNoteMaster.Narration;
                //GridFill
                List<DataTable> listObj = new List<DataTable>();
                CreditNoteBll BllCreditNoteDetailsSp = new CreditNoteBll();
                listObj = BllCreditNoteDetailsSp.CreditNoteDetailsViewByMasterId(decCreditNoteMasterIdForEdit);

                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                for (int inI = 0; inI < listObj[0].Rows.Count; inI++)
                {
                    dgvCreditNote.Rows.Add();
                    dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["ledgerId"].ToString());

                    if (Convert.ToDecimal(listObj[0].Rows[inI]["debit"].ToString()) == 0)
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr";
                        dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["credit"].ToString());
                    }
                    else
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr";
                        dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["debit"].ToString());
                    }
                    dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj[0].Rows[inI]["exchangeRateId"].ToString());
                    if (listObj[0].Rows[inI]["chequeNo"].ToString() != string.Empty)
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value = listObj[0].Rows[inI]["chequeNo"].ToString();
                        dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(listObj[0].Rows[inI]["chequeDate"].ToString())).ToString();
                    }
                    dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value = listObj[0].Rows[inI]["CreditNoteDetailsId"].ToString();

                    decimal decDetailsId1 = Convert.ToDecimal(listObj[0].Rows[inI]["CreditNoteDetailsId"].ToString());
                    decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decCreditNoteVoucherTypeId);
                    dgvCreditNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                    btnSave.Text = "Update";

                }

                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                List<DataTable> listObj1 = new List<DataTable>();
                listObj1 = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decCreditNoteVoucherTypeId, strVoucherNo, infoCreditNoteMaster.Date);

                dtblPartyBalance = listObj1[0];
                dgvCreditNote.ClearSelection();
                txtDate.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:37" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }