Exemplo n.º 1
0
 protected void btn_update_Click(object sender, EventArgs e)
 {
     try
     {
         using (var db = new THFinanceEntities())
         {
             int id = Convert.ToInt32(lbl_id.Text);
             var q  = (from s in db.tbl_borrowerPaymentmethod
                       where s.borrowerPayid.Equals(id)
                       select s).SingleOrDefault();
             tbl_borrowerPaymentmethod tbl = new tbl_borrowerPaymentmethod();
             tbl.borrowerBranchid        = Convert.ToInt32(ddl_branch.SelectedValue);
             tbl.borrowerLoanid          = Convert.ToInt32(ddl_chitti.SelectedValue);
             tbl.borrowermanager         = Convert.ToInt32(ddl_manager.SelectedValue);
             tbl.borrowerName            = Convert.ToInt32(ddl_Borroerpayeename.SelectedValue);
             tbl.borrowerPayamount       = txt_paidAmount.Text;
             tbl.borrowerPaymentdate     = Convert.ToDateTime(txt_startdate.Text);
             tbl.totalpayment            = txt_amount.Value;
             tbl.borrowerReaminingamount = txt_remainingAmount.Text;
             tbl.borrowerPenalitydays    = Convert.ToInt32(txt_penalitydays.Value);
             tbl.modified     = Convert.ToInt32(Session["UserID"]);
             tbl.modifieddate = DateTime.Now;
             if (tbl != null)
             {
                 //  db.tbl_borrower.Add(q);
                 db.SaveChanges();
                 clearfields();
                 loadgrid();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new THFinanceEntities())
                {
                    tbl_borrowerPaymentmethod tbl = new tbl_borrowerPaymentmethod();
                    int id   = Convert.ToInt32(ddl_Borroerpayeename.SelectedValue);
                    int days = Convert.ToInt32(txt_penalitydays.Value);
                    var q    = (from s in db.tbl_PaymentType
                                where s.paymentBorrowerId.Equals(id)
                                select s).ToList();
                    // txt_penalitydays.Value = "0";
                    if (ddl_chitti.SelectedValue == "1")
                    {
                        //txt_penalitydays.Value = Convert.ToString(dayscount);
                    }
                    else
                    {
                    }

                    DateTime fromdate = DateTime.Parse(Convert.ToDateTime(txt_startdate.Text).ToShortDateString());
                    DateTime todate   = DateTime.Parse(Convert.ToDateTime(txt_enddate.Value).ToShortDateString());
                    if (fromdate > todate)
                    {
                        Response.Write("<script>alert('please select today date')</script>");
                        return;
                    }
                    else
                    {
                        tbl.borrowerBranchid        = Convert.ToInt32(ddl_branch.SelectedValue);
                        tbl.borrowerLoanid          = Convert.ToInt32(ddl_chitti.SelectedValue);
                        tbl.borrowerName            = Convert.ToInt32(ddl_Borroerpayeename.SelectedValue);
                        tbl.borrowermanager         = Convert.ToInt32(ddl_manager.SelectedValue);
                        tbl.borrowerPayamount       = txt_paidAmount.Text;
                        tbl.borrowerReaminingamount = txt_remainingAmount.Text;
                        tbl.borrowerPaymentdate     = todate;
                        tbl.borrowerPenalitydays    = Convert.ToInt32(txt_penalitydays.Value);
                        tbl.borrowerStartdate       = Convert.ToDateTime(txt_startdate.Text);
                        tbl.totalpayment            = txt_amount.Value;
                        tbl.createdby   = Convert.ToInt32(Session["UserID"]);
                        tbl.createddate = DateTime.Now;

                        if (ddl_chitti.SelectedValue == "1")
                        {
                            if (Convert.ToDateTime(q[0].PaymentDate) >= tbl.borrowerStartdate.AddDays(100))
                            {
                                if (tbl.borrowerReaminingamount == "0")
                                {
                                    tbl.status = 1;
                                    db.tbl_borrowerPaymentmethod.Add(tbl);
                                    db.SaveChanges();
                                    Response.Write("<script>alert('Payment sucessfully completed ')</script>");
                                    clearfields();
                                    return;
                                }
                                else
                                {
                                    tbl.status = 2;
                                    db.tbl_borrowerPaymentmethod.Add(tbl);
                                    db.SaveChanges();
                                    Response.Write("<script>alert('Payment pending')</script>");
                                    clearfields();
                                    return;
                                }
                            }
                            else
                            {
                                if (ddl_chitti.SelectedValue == "1")
                                {
                                    tbl.borrowerReaminingamount = Convert.ToString(Convert.ToInt32(txt_remainingAmount.Text) + days * 100);
                                    tbl.borrowerStartdate       = todate.AddDays(1);
                                }
                                else
                                {
                                    txt_remainingAmount.Text = Convert.ToString(Convert.ToInt32(txt_remainingAmount.Text) + days * 10);
                                    tbl.borrowerStartdate    = todate.AddMonths(1);
                                }
                                tbl.status = 0;
                                db.tbl_borrowerPaymentmethod.Add(tbl);
                                db.SaveChanges();
                                Response.Write("<script>alert('Sucessfully Saved')</script>");
                                clearfields();
                                return;
                            }
                        }

                        else
                        {
                            if (tbl.borrowerPaymentdate >= tbl.borrowerStartdate.AddMonths(12))
                            {
                                if (tbl.borrowerReaminingamount == "0")
                                {
                                    tbl.status = 1;
                                    db.tbl_borrowerPaymentmethod.Add(tbl);
                                    db.SaveChanges();
                                    Response.Write("<script>alert('Payment sucessfully completed ')</script>");
                                    clearfields();
                                    return;
                                }
                                else
                                {
                                    tbl.status = 2;
                                    db.tbl_borrowerPaymentmethod.Add(tbl);
                                    db.SaveChanges();
                                    Response.Write("<script>alert('Payment pending')</script>");
                                    clearfields();
                                    return;
                                }
                            }
                            else
                            {
                                if (ddl_chitti.SelectedValue == "1")
                                {
                                    txt_remainingAmount.Text = Convert.ToString(Convert.ToInt32(txt_remainingAmount.Text) + days * 100);
                                    tbl.borrowerStartdate    = todate.AddDays(1);
                                }
                                else
                                {
                                    txt_remainingAmount.Text = Convert.ToString(Convert.ToInt32(txt_remainingAmount.Text) + days * 10);
                                    tbl.borrowerStartdate    = todate.AddMonths(1);
                                }
                                tbl.status = 0;
                                db.tbl_borrowerPaymentmethod.Add(tbl);
                                db.SaveChanges();
                                Response.Write("<script>alert('Sucessfully Saved')</script>");
                                clearfields();
                                return;
                            }
                        }
                        //if(tbl.borrowerStartdate == tbl.borrowerStartdate.AddMonths(12))
                        //{
                        //    if (tbl.borrowerReaminingamount == "0")
                        //    {

                        //        status = 1;
                        //        Response.Write("<script>alert('Payment sucessfully completed ')</script>");
                        //        return;

                        //    }
                        //    else
                        //    {
                        //        status = 2;

                        //    }

                        //}
                        //    if (tbl.borrowerReaminingamount=="0")
                        //{

                        //    status = 1;
                        //    Response.Write("<script>alert('Payment sucessfully completed ')</script>");
                        //    return;

                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }