protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["role"].ToString() != "Admin")
            {
                string s = "Access denied";
                Response.Redirect("login.aspx" + s);
            }
            carrentalEntities db = new carrentalEntities();


            DataTable dt = new DataTable();

            using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("SELECT b.cid,b.rating,b.fid,b.carno FROM feedback AS b", con);
                // cmd.Parameters.AddWithValue("@dnow", DateTime.Now);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                con.Close();
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
            Label1.Visible   = false;
            TextBox1.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();
        }
        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;
        }
Esempio n. 4
0
        private void sendmail(string subject)
        {
            string sender = (string)Application["sender_email"];
            string server = (string)Application["sender_server"];
            int    owid3  = Int32.Parse(ownid.Text);

            carrentalEntities db      = new carrentalEntities();
            owner             oo      = db.owners.Where(x => x.oid == owid3).FirstOrDefault <owner>();
            string            emailid = oo.email;
            //Response.Write(emailid);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(sender);
            mail.To.Add(new MailAddress(emailid));
            mail.Subject = subject;
            mail.Body    = "Your Car Request has been accepted.Your Carno:" + carno.Text.ToString();
            mail.Body   += "Offered rentprice:" + rentprice.Text.ToString();

            SmtpClient smtp = new SmtpClient(server, 587);

            smtp.EnableSsl      = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Credentials    = new System.Net.NetworkCredential(sender, "Qtnsqc16");
            smtp.Send(mail);
        }
Esempio n. 5
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);
             */
        }
        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;
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var db = new carrentalEntities();
            IQueryable <Cardetail> query;

            query = from i in db.Cardetails
                    select i;

            ListView1.DataSource = query.ToList();
            ListView1.DataBind();
        }
Esempio n. 8
0
        protected void get_Click(object sender, EventArgs e)
        {
            string sendr  = (string)Application["sender_email"];
            string server = (string)Application["sender_server"];
            string role   = DropDownList1.SelectedItem.Text;

            string            s = Email.Text.Trim().ToString();
            carrentalEntities c = new carrentalEntities();
            var k    = (from u in c.Logins where u.LoginId == s && u.Role == role select u);
            var user = (from u in c.Logins where u.LoginId == s && u.Role == role select u).FirstOrDefault();

            foreach (var i in k)
            {
                pwd = i.Password.ToString();
                //unm = i.Username.ToString();
            }
            if (user == null)
            {
                //Response.Write("hello");
                msg.Text    = "User not exist";
                msg.Visible = true;
            }
            else
            {
                try
                {
                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress(sendr);

                    mail.To.Add(new MailAddress(Email.Text.ToString()));
                    mail.Subject = "your Login credentials";
                    mail.Body    = "Your LoginId is your email" + " " + "Your Password is:" + pwd;



                    SmtpClient smtp = new SmtpClient(server, 587);
                    smtp.EnableSsl      = true;
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.Credentials    = new System.Net.NetworkCredential(sendr, "Qtnsqc16");
                    smtp.Send(mail);
                    Response.Redirect("~/login.aspx?msg=mail+sent");

                    Response.Write(mail.Body);
                }
                catch (Exception err)
                {
                    //Response.Write(err);
                    msg.Text    = "Mail not sent try again";
                    msg.Visible = true;
                }
            }
        }
Esempio n. 9
0
        protected void submit_Click(object sender, EventArgs e)
        {
            carrentalEntities db = new carrentalEntities();
            feedback          f  = new feedback();

            f.carno       = cno.Text.ToString();
            f.cid         = Int32.Parse(cid.Text);
            f.rating      = DropDownList1.SelectedItem.Text;
            f.description = review.Text;
            db.feedbacks.Add(f);
            db.SaveChanges();
            Response.Redirect("customerprofile.aspx");
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label1.Visible   = true;
            TextBox1.Visible = true;
            GridViewRow       row = GridView1.SelectedRow;
            carrentalEntities db  = new carrentalEntities();
            feedback          f   = new feedback();
            int      feedbackid   = Int32.Parse(row.Cells[3].Text);
            feedback cc           = db.feedbacks.Where(x => x.fid == feedbackid).FirstOrDefault <feedback>();


            TextBox1.Text = cc.description;
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Role"].ToString() != "Admin")
            {
                string msg = "Access denied";
                Response.Redirect("login.aspx" + msg);
            }

            carrentalEntities db   = new carrentalEntities();
            string            mail = Session["loginid"].ToString();
            admin             aa   = db.admins.Where(x => x.email == mail).FirstOrDefault <admin>();

            username_text.Text = aa.firstname;
        }
        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;
        }
Esempio n. 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            carrentalEntities db = new carrentalEntities();
            var cars             = (from u in db.Cardetails
                                    let vehicleid = from x in db.vehicles
                                                    select x.vehicleid
                                                    select u);
            ListBox l1 = new ListBox();

            foreach (var i in cars)
            {
                l1.Items.Add(i.carno);
                Response.Write(i.carno + "\n");
            }
            PlaceHolder1.Controls.Add(l1);
        }
Esempio n. 14
0
        private void sendmail(string subject)
        {
            string            sender = (string)Application["sender_email"];
            string            server = (string)Application["sender_server"];
            carrentalEntities db     = new carrentalEntities();
            MailMessage       mail   = new MailMessage();

            mail.From = new MailAddress(sender);
            mail.To.Add(new MailAddress(email.Text));
            mail.Subject = subject;
            mail.Body    = "Your loginid is your email and your password is:" + pwd.Text;
            SmtpClient smtp = new SmtpClient(server, 587);

            smtp.EnableSsl      = true;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Credentials    = new System.Net.NetworkCredential(sender, "Qtnsqc16");
            smtp.Send(mail);
        }
Esempio n. 15
0
        protected void add_Click(object sender, EventArgs e)
        {
            carrentalEntities db = new carrentalEntities();
            chauffer          c  = new chauffer();
            Login             l  = new Login();

            pass           = GetStr();
            Session["pwd"] = pass.ToString();
            c.firstname    = firstname.Text;
            c.lastname     = lastname.Text;
            c.licenseno    = licenceno.Text;
            c.address      = address.Text;
            c.salary       = Int32.Parse(salry.Text);
            c.email        = email.Text;
            c.phone        = mobileno.Text;
            string r = "DeliveryPerson";

            l.Role     = r;
            l.LoginId  = email.Text;
            l.Password = pass;
            db.Logins.Add(l);
            db.chauffers.Add(c);


            //db.SaveChanges();


            try
            {
                int n = db.SaveChanges();
                sendmail("Successfully registered");
                msg.Text      = "Successfully registered";
                msg.ForeColor = System.Drawing.Color.Green;
            }
            catch (Exception err)
            {
                //msg.Text = "Some Error Occured";
                // msg.ForeColor = System.Drawing.Color.Red;
                Response.Write(err);
            }
        }
Esempio n. 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["role"].ToString() != "Customer")
            {
                string msg = "Access denied";
                Response.Redirect("login.aspx?" + msg);
            }
            string            s  = Session["loginid"].ToString();
            carrentalEntities db = new carrentalEntities();
            var c = from x in db.customers where x.email == s select x;

            foreach (var x in c)
            {
                cid.Text = x.cid.ToString();
            }
            int i = Int32.Parse(cid.Text);
            var d = from x in db.bookings where x.cid == i select x;

            foreach (var x in d)
            {
                cno.Text = x.carno.ToString();
            }
        }
Esempio n. 17
0
        protected void button1_Click(object sender, EventArgs e)
        {
            carrentalEntities db = new carrentalEntities();
            offer             o  = new offer();

            o.promocode   = promo.Text;
            o.description = desc.Text;
            o.isonetime   = Int32.Parse(ison.SelectedItem.Value);
            o.ofbased     = ofbase.SelectedItem.Text;
            if (ofbase.SelectedItem.Text == "Percentage")
            {
                o.discountpercent = Int32.Parse(per.Text);
                o.discountamount  = 0;
            }
            else if (ofbase.SelectedItem.Text == "Amount")
            {
                o.discountamount  = Int32.Parse(amt.Text);
                o.discountpercent = 0;
            }
            db.offers.Add(o);
            db.SaveChanges();
            msg.Text = "offer added successfuly";
        }
        protected void get_Click(object sender, EventArgs e)
        {
            carrentalEntities db      = new carrentalEntities();
            Login             l       = new Login();
            string            pwd1    = pwd.Text;
            string            pwd2    = cpwd.Text;
            string            role    = Session["role"].ToString();
            string            loginid = Session["loginid"].ToString();
            var user = (from u in db.Logins where u.LoginId == loginid && u.Role == role select u).FirstOrDefault();

            if (pwd1 != pwd2)
            {
                // Response.Redirect("~/changepassword.aspx?msg=password+not+matched");
                msg.Text      = "Password not matched";
                msg.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                user.Password = cpwd.Text;
                db.SaveChanges();
                msg.Text      = "Password changed successfully";
                msg.ForeColor = System.Drawing.Color.Green;
            }
        }
Esempio n. 19
0
        protected void add_Click(object sender, EventArgs e)
        {
            carrentalEntities db      = new carrentalEntities();
            string            role    = DropDownList1.SelectedItem.Text;
            customer          c       = new customer();
            string            fname   = firstname.Text;
            string            lname   = lastname.Text;
            string            mno     = (mobileno.Text);
            string            mail    = email.Text;
            string            license = licenceno.Text;
            string            add     = address.Text;

            if (DropDownList1.SelectedItem.Text == "Customer")
            {
                //Login l = new Login();
                var already = from x in db.Logins
                              where x.LoginId == email.Text && x.Role == role
                              select x;
                int count = 0;
                foreach (var a in already)
                {
                    count++;
                }


                if (count > 0)
                {
                    msg.Text      = "You Have Already Registered, Please Login!!";
                    msg.ForeColor = System.Drawing.Color.Red;
                    return;
                }
                else
                {
                    Login l = new Login();
                    l.Role      = DropDownList1.SelectedItem.Text.ToString();
                    l.LoginId   = email.Text.ToString();
                    l.Password  = pwd.Text;
                    c.email     = email.Text;
                    c.firstname = fname;
                    c.lastname  = lname;
                    c.licenceno = license;
                    c.address   = add;
                    c.mobileno  = mno;
                    db.customers.Add(c);
                    db.Logins.Add(l);
                    try
                    {
                        int n = db.SaveChanges();
                        sendmail("Successfully registered");
                        msg.Text      = "Successfully registered";
                        msg.ForeColor = System.Drawing.Color.Green;
                    }
                    catch (Exception err)
                    {
                        msg.Text      = "Some Error Occured";
                        msg.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            else if (DropDownList1.SelectedItem.Text == "Owner")
            {
                var already = from x in db.Logins
                              where x.LoginId == email.Text && x.Role == role
                              select x;
                int count = 0;
                foreach (var a in already)
                {
                    count++;
                }


                if (count > 0)
                {
                    msg.Text      = "You Have Already Registered, Please Login!!";
                    msg.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    Login p = new Login();
                    owner o = new owner();
                    p.Role      = DropDownList1.SelectedItem.Text.ToString();
                    p.LoginId   = email.Text.ToString();
                    p.Password  = pwd.Text;
                    o.email     = email.Text;
                    o.firstname = fname;
                    o.lastname  = lname;
                    o.address   = add;
                    o.phone     = mno;
                    db.owners.Add(o);
                    db.Logins.Add(p);
                }
                try
                {
                    int k = db.SaveChanges();
                    sendmail("Successfully registered");
                    msg.Text      = "Successfully registered";
                    msg.ForeColor = System.Drawing.Color.Green;
                }
                catch (Exception err)
                {
                    msg.Text      = "Some Error Occured";
                    msg.ForeColor = System.Drawing.Color.Red;
                }
            }
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label2.Visible  = true;
            Label3.Visible  = true;
            Label4.Visible  = true;
            Label5.Visible  = true;
            Label6.Visible  = true;
            Label7.Visible  = true;
            Label8.Visible  = true;
            Label9.Visible  = true;
            Label10.Visible = false;
            string            s  = Session["loginid"].ToString();
            carrentalEntities db = new carrentalEntities();
            customer          cc = db.customers.Where(x => x.email == s).FirstOrDefault <customer>();
            int ci = cc.cid;
            int cid1 = 0, cid2 = 1;
            int bi = Int32.Parse(bid.Text.ToString());
            //  var q = from x in db.bookings where x.cid == ci select x;
            var p = from n in db.bookings where n.bookingid == bi select n;

            /*  if(q.Any())
             * {
             *    foreach(var y in q)
             *    {
             *        cid1 = y.cid;
             *    }
             * }*/
            if (p.Any())
            {
                foreach (var z in p)
                {
                    cid2 = z.cid;
                }
            }
            if (ci == cid2)
            {
                if (p.Any())
                {
                    foreach (var y in p)
                    {
                        Label6.Text = y.carno.ToString();
                        Label7.Text = y.startdate.ToString();
                        Label8.Text = y.enddate.ToString();
                        Label9.Text = y.rentalamount.ToString();
                    }
                }
            }
            else
            {
                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 = true;
                Label10.Text    = "Invalid booking id";
            }
        }
Esempio n. 22
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");
        }
Esempio n. 23
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label8.Visible  = true;
            Label9.Visible  = true;
            Label10.Visible = true;
            Label11.Visible = true;
            string            loginid = Session["loginid"].ToString();
            carrentalEntities db      = new carrentalEntities();
            chauffer          cc      = db.chauffers.Where(x => x.email == loginid).FirstOrDefault <chauffer>();
            int cid     = cc.did;
            int id      = Int32.Parse(bookingid.Text);
            var getdata = from x in db.bookings where x.bookingid == id && x.did == cid select x;

            if (getdata.Any())
            {
                var a = getdata.First();
                carno     = a.carno;
                startdate = a.startdate;
                enddate   = a.enddate;
                int pay = a.rentalamount;
                Label3.Text = carno;
                Label4.Text = startdate.ToString();
                Label5.Text = enddate.ToString();
                Label6.Text = pay.ToString();

                DateTime actenddate = DateTime.Now;
                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;
                if (t >= 0)
                {
                    Label7.Text = t.ToString();
                }
                else
                {
                    Label7.Visible = false;
                }
            }
            else
            {
                Response.Write("Enter valid booking id");
            }
        }
Esempio n. 24
0
        protected void login_Click(object sender, EventArgs e)
        {
            string loginid  = uname.Text;
            string password = pwd.Text;
            string role     = DropDownList1.SelectedItem.Text;

            if (uname.Text == "" || pwd.Text == "")
            {
                msg.Text      = "All details are mandatory.";
                msg.ForeColor = System.Drawing.Color.Red;

                return;
            }
            else
            {
                ExampleCaptcha.UserInputID = CaptchaCodeTextBox.ClientID;
                if (IsPostBack)
                {
                    bool isHuman = ExampleCaptcha.Validate(CaptchaCodeTextBox.Text);
                    CaptchaCodeTextBox.Text = null;
                    if (!isHuman)
                    {
                        msg.Text      = "Incorrect Captcha.";
                        msg.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        try
                        {
                            carrentalEntities db = new carrentalEntities();
                            if (!idflag)
                            {
                                var q = from i in db.Logins where i.LoginId == loginid && i.Role == role && i.Password == password select i;
                                if (q.Any())
                                {
                                    foreach (var i in q)
                                    {
                                        Session["role"]    = i.Role;
                                        Session["loginid"] = i.LoginId;
                                    }
                                    if (Session["role"].ToString() == "Admin")
                                    {
                                        Response.Redirect("Admin.aspx");
                                    }
                                    else if (Session["role"].ToString() == "Customer")
                                    {
                                        Response.Redirect("timecheck.aspx");
                                    }
                                    else if (Session["role"].ToString() == "Owner")
                                    {
                                        Response.Redirect("ownerprofile.aspx");
                                    }
                                    else if (Session["role"].ToString() == "DeliveryPerson")
                                    {
                                        Response.Redirect("chaufferprofile.aspx");
                                    }
                                }
                                else
                                {
                                    msg.Text      = "Incorrect Credentials. Please try again.";
                                    msg.ForeColor = System.Drawing.Color.Red;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            msg.Text      = "Exception";
                            msg.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                }
            }
        }