protected void btnSearch_Click(object sender, EventArgs e)
        {
            int      SupplierId = Convert.ToInt32(ddlSupplier.SelectedValue);
            DateTime?Fromdate;
            DateTime?ToDate;

            if (txtFromDate.Text.Trim().Length == 0)
            {
                Fromdate = null;
            }
            else
            {
                Fromdate = Convert.ToDateTime(txtFromDate.Text.Trim() + " 00:00:00");
            }

            if (txtToDate.Text.Trim().Length == 0)
            {
                ToDate = null;
            }
            else
            {
                ToDate = Convert.ToDateTime(txtToDate.Text.Trim() + " 23:59:59");
            }

            BusinessLayer.Accounts.PurchaseBillPayment ObjPayment = new BusinessLayer.Accounts.PurchaseBillPayment();
            //DataView dv = new DataView(ObjPayment.GetAll(SupplierId, Fromdate, ToDate));
            DataTable dt = ObjPayment.GetAll(SupplierId, Fromdate, ToDate);

            //dv.RowFilter = "CompanyID_FK=" + Convert.ToInt32(Session["CompanyId"].ToString());

            dgvPayment.DataSource = dt;
            dgvPayment.DataBind();
        }
コード例 #2
0
        protected void LoadDueBills()
        {
            int SupplierLedgerId = Convert.ToInt32(ddlSupplierLedger.SelectedValue.Trim());
            int CompanyId        = Convert.ToInt32(Session["CompanyId"].ToString().Trim());

            BusinessLayer.Accounts.PurchaseBillPayment objPayment = new BusinessLayer.Accounts.PurchaseBillPayment();
            DataTable DT = objPayment.GetDueBills(SupplierLedgerId, CompanyId);

            if (DT != null)
            {
                dgvBill.DataSource = DT;
                dgvBill.DataBind();
                txtTotalAmt.Text = "0.00";
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Validate())
            {
                string strValues = txtPaymentDate.Text;
                strValues += chr.ToString() + "";
                DataSet ds_fn = gf.ExecuteSelectSP("spSelect_GetFnYear", strValues);

                if (ds_fn.Tables[0].Rows[0]["FinYearID"].ToString() == Session["FinYrID"].ToString().Trim())
                {
                    BusinessLayer.Accounts.PurchaseBillPayment ObjPayment = new BusinessLayer.Accounts.PurchaseBillPayment();
                    Entity.Accounts.PurchaseBillPayment        Payment    = new Entity.Accounts.PurchaseBillPayment();
                    Payment.PurchaseBillPaymentId = 0;
                    Payment.SupplierLedgerId_FK   = Convert.ToInt32(ddlSupplierLedger.SelectedValue.Trim());
                    Payment.CashBankLedgerID      = Convert.ToInt32(ddlCashBankLedger.SelectedValue.Trim());
                    Payment.TransactionType       = "PAYMENT";
                    Payment.AmountPaid            = Convert.ToDecimal(txtTotalAmt.Text.Trim());
                    Payment.AmountDeducted        = Convert.ToDecimal(txtTotalDeductionAmt.Text.Trim());
                    Payment.PaymentDate           = Convert.ToDateTime(txtPaymentDate.Text.Trim() + " 00:00:00");
                    Payment.ModeOfPayment         = ddlPaymentMode.SelectedValue.Trim();
                    Payment.ChequeNo = txtChequeNo.Text.Trim();

                    if (txtChequeDate.Text.Trim().Length == 0)
                    {
                        Payment.ChequeDate = null;
                    }
                    else
                    {
                        Payment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.Trim() + " 00:00:00");
                    }

                    Payment.DrawnOn   = txtDrawnOn.Text.Trim();
                    Payment.CreatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
                    Payment.CompanyId = Convert.ToInt32(Session["CompanyId"].ToString());
                    Payment.BranchId  = Convert.ToInt32(Session["BranchId"].ToString());
                    Payment.FinYrId   = Convert.ToInt32(Session["FinYrID"].ToString());
                    Payment.Narration = txtNarration.Text.Trim();

                    //-------------------------------------------------------------------------------------//
                    DataTable DT = new DataTable();
                    DT.Columns.Add("PurchaseBillId", typeof(int));
                    DT.Columns.Add("Amount", typeof(decimal));
                    DataRow DR;

                    foreach (GridViewRow GVR in dgvBill.Rows)
                    {
                        if (GVR.RowType == DataControlRowType.DataRow)
                        {
                            TextBox txtAmount = (TextBox)GVR.FindControl("txtAmount");
                            decimal Amount    = (txtAmount.Text.Trim().Length > 0) ? Convert.ToDecimal(txtAmount.Text.Trim()) : 0;

                            if (Amount > 0)
                            {
                                DR = DT.NewRow();
                                DR["PurchaseBillId"] = Convert.ToInt32(dgvBill.DataKeys[GVR.RowIndex].Value.ToString());
                                DR["Amount"]         = Amount;
                                DT.Rows.Add(DR);
                                DT.AcceptChanges();
                            }
                        }
                    }

                    using (DataSet ds = new DataSet())
                    {
                        ds.Tables.Add(DT);
                        Payment.PaymentDetailsXML = ds.GetXml().Replace("Table1>", "Table>");
                    }


                    //---------------------------------------------------------------------------//
                    string DeductionDetails = "";

                    if (ViewState["DeductionDetails"] != null)
                    {
                        DT = (DataTable)ViewState["DeductionDetails"];
                        DT.Columns.Remove("DeductionHead");
                        DT.AcceptChanges();

                        using (DataSet ds = new DataSet())
                        {
                            ds.Tables.Add(DT);
                            DeductionDetails = ds.GetXml().Replace("Table1>", "Table>");
                        }
                    }

                    Payment.DeductionDetailsXML       = DeductionDetails;
                    Payment.XMLCashBankVoucherDetails = PrepareXMLString();
                    ObjPayment.Save(Payment);
                    ClearControls();

                    Message.IsSuccess = true;
                    Message.Text      = "Payment Saved Successfully";
                    btnPrint.Attributes.Add("onclick", "javascript:window.open('RPTGridView.aspx?ID=" + Payment.CBVHeaderID + "'); return false;");
                }
                else
                {
                    Message.IsSuccess = false;
                    Message.Text      = "Please select a Date Between " + Session["SesFromDate"].ToString() + " & " + Session["SesToDate"].ToString() + "";
                }
            }
            Message.Show = true;
        }