コード例 #1
0
ファイル: frmPayment.cs プロジェクト: joemash/school-erp
        /// <summary>
        /// Save Function
        /// </summary>
        public void Save()
        {
            try
            {
                int inGridRowCount  = dgvPayment.RowCount;
                int inTableRowCount = dtblPartyBalance.Rows.Count;
                int inB             = 0;
                PaymentMasterInfo  InfoPaymentMaster  = new PaymentMasterInfo();
                PaymentMasterSP    SpPaymentMaster    = new PaymentMasterSP();
                PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo();
                PaymentDetailsSP   SpPaymentDetails   = new PaymentDetailsSP();
                //PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); NOT IMPLEMENTED
                //PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); NOT IMPLEMENTED
                //DateValidation objVal = new DateValidation();
                TextBox txtDate1 = new TextBox();
                InfoPaymentMaster.VoucherNo = strVoucherNo;

                txtDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");

                InfoPaymentMaster.Date            = Convert.ToDateTime(txtDate.Text);
                InfoPaymentMaster.Extra1          = string.Empty;
                InfoPaymentMaster.Extra2          = string.Empty;
                InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                InfoPaymentMaster.InvoiceNo       = txtVoucherNo.Text.Trim();
                InfoPaymentMaster.LedgerId        = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString());
                InfoPaymentMaster.Narration       = txtNarration.Text.Trim();
                InfoPaymentMaster.SuffixPrefixId  = decDailySuffixPrefixId;
                decimal decTotalAmount = TotalAmountCalculation();
                InfoPaymentMaster.TotalAmount = decTotalAmount;
                InfoPaymentMaster.UserId      = PublicVariables._decCurrentUserId;

                //InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId;
                decimal decPaymentMasterId = SpPaymentMaster.PaymentMasterAdd(InfoPaymentMaster);
                if (decPaymentMasterId != 0)
                {
                    MasterLedgerPosting();
                }
                for (int inI = 0; inI < inGridRowCount - 1; inI++)
                {
                    if (dgvPayment.Rows[inI].HeaderCell.Value.ToString() != "X")
                    {
                        InfoPaymentDetails.Amount          = Convert.ToDecimal(dgvPayment.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                        InfoPaymentDetails.ExchangeRateId  = Convert.ToDecimal(dgvPayment.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        InfoPaymentDetails.Extra1          = string.Empty;
                        InfoPaymentDetails.Extra2          = string.Empty;
                        InfoPaymentDetails.LedgerId        = Convert.ToDecimal(dgvPayment.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        InfoPaymentDetails.PaymentMasterId = decPaymentMasterId;
                        if (dgvPayment.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPayment.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPayment.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        }
                        if (dgvPayment.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPayment.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            InfoPaymentDetails.ChequeNo = dgvPayment.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();

                            if (dgvPayment.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPayment.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPayment.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                InfoPaymentDetails.ChequeDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            InfoPaymentDetails.ChequeNo   = string.Empty;
                            InfoPaymentDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsAdd(InfoPaymentDetails);
                        if (decPaymentDetailsId != 0)
                        {
                            inB++;
                            DetailsLedgerPosting(inI, decPaymentDetailsId);
                        }
                    }
                }

                //Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }