Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["role"].ToString() != "Customer")
            {
                string msg = "Access denied";
                Response.Redirect("login.aspx?" + msg);
            }
            carrentalEntities db   = new carrentalEntities();
            string            mail = Session["loginid"].ToString();
            customer          cc   = db.customers.Where(x => x.email == mail).FirstOrDefault <customer>();
            int       customerid   = cc.cid;
            booking   bb           = db.bookings.Where(x => x.cid == customerid).FirstOrDefault <booking>();
            DataTable dt           = new DataTable();

            using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                con.Open();
                SqlCommand     cmd = new System.Data.SqlClient.SqlCommand("SELECT b.bookingid,b.carno,b.startdate,b.enddate,b.rentalamount,b.did FROM booking AS b where b.cid=" + customerid + "", con);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                da.Fill(dt);
                con.Close();
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
            address.Visible = false;
            addr.Visible    = false;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["role"].ToString() != "DeliveryPerson")
            {
                string s = "Access denied";
                Response.Redirect("login.aspx" + s);
            }
            carrentalEntities db   = new carrentalEntities();
            string            mail = Session["loginid"].ToString();
            chauffer          cc   = db.chauffers.Where(x => x.email == mail).FirstOrDefault <chauffer>();
            int       driverid     = cc.did;
            booking   bb           = db.bookings.Where(x => x.did == driverid).FirstOrDefault <booking>();
            DataTable dt           = new DataTable();

            using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SELECT b.bookingid,b.cid,b.startdate,b.enddate FROM booking AS b where (b.startdate>=@dnow) AND b.did=" + driverid + "", con);
                cmd.Parameters.AddWithValue("@dnow", DateTime.Now);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                con.Close();
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
Exemplo n.º 3
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            string otpl = "";

            otpl = (Session["otp"]).ToString();
            int bid = Int32.Parse(Session["bookingid"].ToString());


            if (otp.Text == otpl)
            {
                //Response.Write("otp matched");
                payment p = new payment();
                p.amountpaid = Int32.Parse(Label6.Text);
                p.bookingid  = Int32.Parse(Session["bookingid"].ToString());
                //p.bookingid = 0;
                p.paymentmode = DropDownList1.SelectedItem.Text;
                p.nameoncard  = cardname.Text;
                p.cardno      = (cardno.Text);
                p.phone       = phoneno.Text;
                p.date        = DateTime.Now;
                db.payments.Add(p);
                db.SaveChanges();
                Label7.Text = "payment done succesfully";
                booking bb = db.bookings.Where(x => x.bookingid == bid).FirstOrDefault <booking>();
                Session["amount"]  = Int32.Parse(Label6.Text);
                Session["address"] = bb.address.ToString();
                Response.Redirect("viewpayslip.aspx");
            }
            else
            {
                Label7.Text = "otp doesn't matched";
                //Response.Write("error");
            }
        }
Exemplo n.º 4
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Label2.Visible  = false;
            Label3.Visible  = false;
            Label4.Visible  = false;
            Label5.Visible  = false;
            Label6.Visible  = false;
            Label7.Visible  = false;
            Label8.Visible  = false;
            Label9.Visible  = false;
            Label10.Visible = false;
            int bookingid        = Int32.Parse(bid.Text.ToString());
            carrentalEntities db = new carrentalEntities();
            DateTime          dt = Convert.ToDateTime(Label7.Text);
            DateTime          ct = DateTime.Now;
            TimeSpan          t  = dt.Subtract(ct);
            double            hr = t.TotalHours;

            if (hr > 24)
            {
                booking b = db.bookings.Where(x => x.bookingid == bookingid).FirstOrDefault <booking>();

                var q2 = (from p in db.bookings where p.bookingid == bookingid select p).ToList();
                if (q2.Any())
                {
                    foreach (var i in q2.Where(w => w.bookingid == bookingid))
                    {
                        i.status = "cancelled";
                    }
                }
                string   cno = Label6.Text;
                DateTime dt1 = Convert.ToDateTime(Label7.Text);
                DateTime dt2 = Convert.ToDateTime(Label8.Text);

                var s = (from y in db.carstatus
                         where y.carno == cno && y.startdate == dt1 && y.enddate == dt2
                         select y).FirstOrDefault();
                db.carstatus.Remove(s);
                db.SaveChanges();
                Response.Redirect("customerprofile.aspx");
                Label10.Visible = true;
            }
            else
            {
                Label10.Visible = true;
                Label10.Text    = "Sorry you can't cancel the booking!!!";
                string m = "Sorry you can't cancel the booking!!!";

                Response.Redirect("timecheck.aspx?" + m);
            }

            /*string cno = Label6.Text;
             * DateTime sd = Convert.ToDateTime(Label7.Text);
             * DateTime ed = Convert.ToDateTime(Label8.Text);
             * carstatu c = db.carstatus.Where(s => s.carno == cno && s.startdate == sd && s.enddate == ed).FirstOrDefault<carstatu>();
             * db.carstatus.Remove(c);
             */
        }
Exemplo n.º 5
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow       row = GridView1.SelectedRow;
            carrentalEntities db  = new carrentalEntities();
            int     bookid        = Int32.Parse(row.Cells[1].Text);
            booking bb            = db.bookings.Where(x => x.bookingid == bookid).FirstOrDefault <booking>();

            address.Text    = bb.address;
            address.Visible = true;
            addr.Visible    = true;
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow       row = GridView1.SelectedRow;
            carrentalEntities db  = new carrentalEntities();
            int customerid        = Int32.Parse(row.Cells[2].Text);

            customer cc = db.customers.Where(x => x.cid == customerid).FirstOrDefault <customer>();

            name.Text  = cc.firstname;
            email.Text = cc.email;
            phone.Text = cc.mobileno;
            booking bb = db.bookings.Where(x => x.cid == customerid).FirstOrDefault <booking>();

            address.Text = bb.address;
        }
Exemplo n.º 7
0
        protected void book_Click(object sender, EventArgs e)
        {
            carrentalEntities db   = new carrentalEntities();
            booking           b    = new booking();
            cardata           cd   = new cardata();
            string            mail = Session["loginid"].ToString();
            int custid;
            var q = from i in db.customers where i.email == mail select i;

            if (q.Any())
            {
                foreach (var i in q)
                {
                    b.cid = i.cid;
                }
            }
            DateTime d1 = Convert.ToDateTime(Session["startdate"].ToString());
            DateTime d2 = Convert.ToDateTime(Session["enddate"].ToString());
            // var a = ((from x in db.carstatus where ((d1 >= x.startdate) && (d1 <= x.enddate)) || ((d2 >= x.startdate) && (d2 <= x.enddate)) select x.did));

            //var ab = (from y in db.chauffers select y.did).ToList();
            //var ans = ab.Except(a);
            //Response.Write(ans);
            string check = "SELECT did FROM chauffer  WHERE did NOT IN(SELECT did FROM carstatus AS cs WHERE ((@d1 >= cs.startdate) AND (@d1 <= cs.enddate)) OR ((@d2 >= cs.startdate) AND (@d2 <= cs.enddate)) )";

            cmd.Parameters.AddWithValue("@d1", Convert.ToDateTime(Session["startdate"].ToString()));
            cmd.Parameters.AddWithValue("@d2", Convert.ToDateTime(Session["enddate"].ToString()));
            myconn.Open();
            cmd.CommandText = check;
            SqlDataReader rdr      = cmd.ExecuteReader();
            int           driverid = 0;

            while (rdr.Read())
            {
                driverid = Int32.Parse(rdr["did"].ToString());
                break;
            }
            //Response.Write(driverid);
            b.startdate    = Convert.ToDateTime(one + " " + two);
            b.enddate      = Convert.ToDateTime(three + " " + four);
            b.rentalamount = Int32.Parse(ppay.Text.ToString());
            //b.type = "Rent";
            b.carno   = Session["carno"].ToString();
            b.did     = driverid;
            b.month   = mo;
            b.year    = yr;
            b.address = address.Text;
            db.bookings.Add(b);
            string no = Session["carno"].ToString();


            /*  var q2 = (from p in db.cardatas where p.carno == no select p).ToList();
             * if(q2.Any())
             * {
             *    foreach(var i in q2.Where(w=>w.carno==no))
             *    {
             *        //i.status = "booked";
             *
             *    }
             * }*/
            carstatu cr = new carstatu();

            cr.carno     = Session["carno"].ToString();
            cr.startdate = Convert.ToDateTime(one + " " + two);
            cr.enddate   = Convert.ToDateTime(three + " " + four);
            cr.status    = "booked";
            cr.did       = driverid;
            db.carstatus.Add(cr);

            db.SaveChanges();
            double tot = Double.Parse(ppay.Text);

            Session["pay"] = (int)tot;
            int id = (from record in db.bookings orderby record.bookingid descending select record.bookingid).First();

            //for generating payslip
            Session["bookingid"] = id.ToString();
            booking bb = db.bookings.Where(x => x.bookingid == id).FirstOrDefault <booking>();

            Session["st_date"] = bb.startdate.ToString();
            Session["ed_date"] = bb.enddate.ToString();
            Session["carno"]   = bb.carno.ToString();
            cardata cx    = db.cardatas.Where(y => y.carno == bb.carno.ToString()).FirstOrDefault <cardata>();
            int     ve_id = cx.vehicleid;
            vehicle vv    = db.vehicles.Where(yy => yy.vehicleid == ve_id).FirstOrDefault <vehicle>();

            Session["model"]    = vv.model.ToString();
            Session["brand"]    = vv.brand.ToString();
            Session["color"]    = vv.color.ToString();
            Session["capacity"] = vv.capacity.ToString();
            Session["mileage"]  = vv.mileage.ToString();
            Session["address"]  = bb.address.ToString();


            Response.Redirect("applyoffer.aspx");
        }
Exemplo n.º 8
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            carrentalEntities db = new carrentalEntities();
            int      id          = Int32.Parse(bookingid.Text);
            DateTime actenddate  = DateTime.Now;

            // Session["pay"] = t.ToString();
            carno = Label3.Text;

            booking  b       = new booking();
            TimeSpan ts      = actenddate.Subtract(enddate);
            double   hr      = ts.TotalHours;
            var      vid     = from p in db.cardatas where p.carno == carno select p;
            int      vehicle = 0;

            if (vid.Any())
            {
                foreach (var y in vid)
                {
                    vehicle = y.vehicleid;
                }
            }

            var rent   = from z in db.vehicles where z.vehicleid == vehicle select z;
            int renthr = 0;

            if (rent.Any())
            {
                foreach (var y in rent)
                {
                    renthr = y.priceperday;
                }
            }


            //  total = renthr * hr * 1.05;
            // int t = (int)total;



            var q2 = (from p in db.bookings where p.bookingid == id select p).ToList();

            if (q2.Any())
            {
                foreach (var i in q2.Where(w => w.bookingid == id))
                {
                    i.status        = "returned";
                    i.actualenddate = actenddate;
                    i.penaltyamount = Int32.Parse(Label7.Text);
                }
            }

            string   cno = Label3.Text.ToString();
            DateTime dt1 = Convert.ToDateTime(Label4.Text.ToString());
            DateTime dt2 = Convert.ToDateTime(Label5.Text.ToString());
            var      x   = (from y in db.carstatus where y.carno == cno && y.startdate == dt1 && y.enddate == dt2
                            select y).FirstOrDefault();

            db.carstatus.Remove(x);
            db.SaveChanges();

            string msg = "car returned successfully!!";

            Response.Redirect("chaufferprofile.aspx?" + msg);
        }