protected void btn_payee_Click(object sender, EventArgs e)
        {
            db = new THFinanceEntities();
            tbl_payment tbl  = new tbl_payment();
            tbl_payee   tbl2 = new tbl_payee();



            tbl.managerId       = Convert.ToInt32(ddl_manager.SelectedValue);
            tbl.branchId        = Convert.ToInt32(ddl_branch.SelectedValue);
            tbl.paymentmethod   = Convert.ToInt32(ddl_chitti.SelectedValue);
            tbl.prepayDate      = Convert.ToDateTime(txt_startdate.Text);
            tbl.presentDate     = Convert.ToDateTime(txt_enddate.Value);
            tbl.paidAmount      = Convert.ToInt32(txt_paidAmount.Text);
            tbl.remainingAmount = Convert.ToInt32(txt_remainingAmount.Text);
            tbl.name            = Convert.ToInt32(ddl_payeename.SelectedValue);
            tbl.totalPayment    = Convert.ToInt32(txt_amount.Value);
            var ts = (from t in db.tbl_payee
                      where t.ID.Equals(tbl.name)
                      select t).ToList();

            // TimeSpan ts = tbl.presentDate - tbl.prepayDate;
            if (tbl.prepayDate.ToShortDateString() == tbl.presentDate.ToShortDateString())
            {
                Response.Write("<script>alert('please select diffrent date')</script>");
                return;
            }
            int count = (tbl.presentDate - tbl.prepayDate).Days;

            tbl.remainingdays = (100 - (tbl.presentDate - ts[0].startdate).Days) + "/100 days";
            if (count >= 3)
            {
                for (int i = 0; i < count / 3; i++)
                {
                    tbl.remainingAmount = tbl.remainingAmount + 100;
                }
            }
            db.tbl_payment.Add(tbl);
            db.SaveChanges();
        }
Exemple #2
0
        protected void btn_newpayee_Click(object sender, EventArgs e)
        {
            db = new THFinanceEntities();
            tbl_payee tbl = new tbl_payee();

            tbl.branchId      = Convert.ToInt32(ddl_branch.SelectedValue);
            tbl.managerId     = Convert.ToInt32(ddl_manager.SelectedValue);
            tbl.paymentmethod = Convert.ToInt32(ddl_chitti.SelectedValue);
            tbl.payeeProof    = txt_payeeproof.Value.ToString();
            txt_payeeproof.PostedFile.SaveAs(Server.MapPath("~/Uploads") + tbl.payeeProof);
            tbl.amount = Convert.ToInt32(txt_amount.Text);

            tbl.NomineeProof = txt_nomineeproof.Value.ToString();
            txt_nomineeproof.PostedFile.SaveAs(Server.MapPath("~/Uploads") + tbl.NomineeProof);
            tbl.name        = txt_name.Text;
            tbl.NomineeName = txt_Nominee.Text;
            tbl.startdate   = Convert.ToDateTime(txt_startdate.Value);
            tbl.enddate     = Convert.ToDateTime(txt_enddate.Value);
            tbl.givenamount = Convert.ToInt32(txt_givenamount.Value);
            db.tbl_payee.Add(tbl);
            db.SaveChanges();
            Response.Write("<script>alert('Sucessfully Saved')</script>");
            clearfields();
        }