Пример #1
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");
            }
        }
Пример #2
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);
             */
        }
Пример #3
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");
        }
Пример #4
0
        protected void add_Click1(object sender, EventArgs e)
        {
            one   = sdate.Text;
            two   = starttime.Text;
            three = edate.Text;
            four  = endtime.Text;


            string mail   = Session["loginid"].ToString();
            owner  oo     = db.owners.Where(x => x.email == mail).FirstOrDefault <owner>();
            string status = "pending";

            cd.carno         = carno.Text;
            cd.color         = color.Text;
            cd.brand         = brand.Text;
            cd.model         = model.Text;
            cd.capacity      = Int32.Parse(capacity.Text);
            cd.mileage       = Double.Parse(mileage.Text);
            cd.requeststatus = status;
            cd.rentprice     = Int32.Parse(rentp.Text);
            cd.startdate     = Convert.ToDateTime(one + " " + two);
            cd.enddate       = Convert.ToDateTime(three + " " + four);
            cd.requeststatus = status;
            cd.oid           = oo.oid;

            postedfile = carimage.PostedFile;
            string       str    = Path.GetFileName(postedfile.FileName);
            Stream       stream = postedfile.InputStream;
            BinaryReader br     = new BinaryReader(stream);

            br.ReadBytes((int)stream.Length);
            cd.carimage = "~/Cars_pic/" + str;
            postedfile.SaveAs(Server.MapPath("~/Cars_pic/") + str);
            db.carrequests.Add(cd);

            try
            {
                int n = db.SaveChanges();
                msg.Text      = "Car request sent successfully";
                msg.ForeColor = System.Drawing.Color.Green;
            }
            catch (Exception err)
            {
                msg.Text      = "Some Error Occured";
                msg.ForeColor = System.Drawing.Color.Red;
            }
        }
Пример #5
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);
            }
        }
Пример #6
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;
            }
        }
Пример #8
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;
                }
            }
        }
Пример #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string s = TextBox1.Text;
            var    a = from x in db.offers where x.promocode == s select x;

            if (a.Any())
            {
                var    i       = a.First();
                string check   = (i.isonetime).ToString();
                int    offerid = (i.offerid);
                string email   = Session["loginid"].ToString();
                var    cust    = from x in db.customers where x.email == email select x;
                int    cid     = 0;
                foreach (var zi in cust)
                {
                    cid = zi.cid;
                }

                if (check == "1")
                {
                    var used = from y in db.offeruseds where y.cid == cid && y.offerid == offerid select y;
                    if (!used.Any())
                    {
                        Response.Write("promocode applied");
                        offerused ou = new offerused();
                        // string email = Session["loginid"].ToString();
                        //string email = "*****@*****.**";
                        var cuid = from z in db.customers where z.email == email select z;
                        var m    = cuid.First();
                        ou.cid     = Int32.Parse(m.cid.ToString());
                        ou.offerid = Int32.Parse(i.offerid.ToString());
                        //Response.Write(m.cid.ToString());
                        //Response.Write(i.offerid.ToString());
                        try
                        {
                            db.offeruseds.Add(ou);
                        }
                        catch (Exception)
                        {
                            Response.Write("hii");
                        }
                        db.SaveChanges();
                        string onbased = i.ofbased.ToString();
                        if (onbased == "percent")
                        {
                            int per = Int32.Parse(i.discountpercent.ToString());
                            pay            = (int)(pay - (pay * per / 100));
                            Session["pay"] = pay.ToString();
                        }
                        else
                        {
                            int amount = Int32.Parse(i.discountamount.ToString());
                            pay            = pay - amount;
                            Session["pay"] = pay.ToString();
                        }
                        Label1.Text = pay.ToString();
                    }
                    else
                    {
                        Label2.Text = "you already used it";
                    }
                }
                else
                {
                    Label2.Text = "no service available";
                    string onbased = i.ofbased.ToString();
                    if (onbased == "percent")
                    {
                        int per = Int32.Parse(i.discountpercent.ToString());
                        pay            = (int)(pay - (pay * per / 100));
                        Session["pay"] = pay.ToString();
                    }
                    else
                    {
                        int amount = Int32.Parse(i.discountamount.ToString());
                        pay            = pay - amount;
                        Session["pay"] = pay.ToString();
                    }
                    Label1.Text = pay.ToString();
                }
            }
            else
            {
                Label2.Text = "no promocode";
            }
        }
Пример #10
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");
        }
Пример #11
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);
        }
Пример #12
0
        protected void add_Click(object sender, EventArgs e)
        {
            string  brand2    = brand.Text;
            string  model2    = model.Text;
            string  color2    = color.Text;
            int     capacity2 = Int32.Parse(capacity.Text);
            double  mileage2  = Double.Parse(mileage.Text);
            string  no2       = carno.Text;
            string  image2    = carimage.Text;
            int     sp2       = Int32.Parse(rentprice.Text);
            int     oid2      = Int32.Parse(ownid.Text);
            vehicle v         = new vehicle();

            v.brand    = brand2;
            v.model    = model2;
            v.color    = color2;
            v.capacity = capacity2;
            v.mileage  = mileage2;
            // v.carno = no2;
            myconn         = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            cmd            = new SqlCommand();
            cmd.Connection = myconn;
            myconn.Open();
            update = "update vehicle set quantity=quantity+" + 1 + "where model=@model and brand=@brand and color=@color";
            cmd.Parameters.AddWithValue("@model", model2);
            cmd.Parameters.AddWithValue("@brand", brand2);
            cmd.Parameters.AddWithValue("@color", color2);

            // myconn.Open();
            cmd.CommandText = update;
            int r = cmd.ExecuteNonQuery();

            if (r == 0)
            {
                string insert = "insert into vehicle (color,model,brand,capacity,mileage,quantity,priceperday) values(@color2,@model2,@brand2,@capacity2,@mileage2,@quantity2,@priceperday2)";
                cmd.Parameters.AddWithValue("@color2", color2);
                cmd.Parameters.AddWithValue("@model2", model2);
                cmd.Parameters.AddWithValue("@brand2", brand2);
                cmd.Parameters.AddWithValue("@capacity2", capacity2);
                cmd.Parameters.AddWithValue("@mileage2", mileage2);
                //cmd.Parameters.AddWithValue("@capacit", capacity2);
                cmd.Parameters.AddWithValue("@quantity2", 1);
                cmd.Parameters.AddWithValue("@priceperday2", pph.Text);



                cmd.CommandText = insert;
                cmd.ExecuteNonQuery();
                myconn.Close();

                id = (from record in db.vehicles orderby record.vehicleid descending select record.vehicleid).First();
                cardata cd = new cardata();
                cd.carimage  = image2;
                cd.rentprice = sp2;
                cd.carno     = no2;
                cd.vehicleid = id;
                cd.startdate = Convert.ToDateTime(sdate.Text.ToString());
                cd.enddate   = Convert.ToDateTime(edate.Text.ToString());
                cd.oid       = oid2;
                db.cardatas.Add(cd);
                db.SaveChanges();
                try
                {
                    sendmail("Your car request has been accepted");
                }
                catch (Exception exp)
                {
                    Response.Write(exp);
                }
            }
            else
            {
                id = (from record in db.vehicles where  record.brand == brand2 && record.model == model2 && record.color == color2 select record.vehicleid).First();
                cardata cd = new cardata();
                cd.carimage  = image2;
                cd.rentprice = sp2;
                cd.carno     = no2;
                cd.vehicleid = id;
                cd.startdate = Convert.ToDateTime(sdate.Text.ToString());
                cd.enddate   = Convert.ToDateTime(edate.Text.ToString());
                cd.oid       = oid2;

                db.cardatas.Add(cd);
                db.SaveChanges();
                try
                {
                    sendmail("Your car request has been accepted");
                }
                catch (Exception exp)
                {
                    Response.Write(exp);
                }
            }

            /* var vid=from x in db.vehicles where x.carno==cd.carno select x.vehicleid;
             * vlid = int.Parse(vid.ToString());
             */
        }