コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string             iname = Session["id"].ToString();
            Database1Entities4 db    = new Database1Entities4();
            Item_DB            it    = db.Item_DB.Where(i => i.I_name == iname).FirstOrDefault <Item_DB>();

            if (it != null)
            {
                Session["iid"]  = it.I_id;
                Session["ccid"] = it.cc_id;

                float finalcost;

                float dcost = (float)it.i_cost - (float)((it.i_cost) * (it.i_discount)) / (100);
                finalcost = (float)(Int32.Parse(TextBox1.Text)) + dcost;
                int exd = Int32.Parse(TextBox1.Text) / 30;
                Label3.Text      = "Your final amount after discount is : " + finalcost.ToString();
                Session["fcost"] = finalcost.ToString();
                DateTime t  = System.DateTime.Today;
                DateTime nt = t.AddDays(exd + 1);
                Session["ddate"] = nt.ToShortDateString();

                Label4.Text     = "Estimated Date of delivery: " + nt.ToShortDateString();
                Button2.Enabled = true;
            }
        }
コード例 #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Database1Entities4 db = new Database1Entities4();

            string date = Session["ddate"].ToString();
            string iid  = Session["iid"].ToString();

            order_details od = new order_details();

            od.i_id     = Session["iid"].ToString();
            od.cc_id    = Session["ccid"].ToString();
            od.c_id     = Session["cid"].ToString();
            od.o_status = "In Process";
            od.o_date   = Session["ddate"].ToString();
            od.o_cost   = Session["fcost"].ToString();
            db.order_details.Add(od);
            db.SaveChanges();

            // Database1Entities4 db1 = new Database1Entities4();
            Item_DB it  = db.Item_DB.Where(i => i.I_id == iid).FirstOrDefault <Item_DB>();
            int     iq  = it.i_quantity;
            int     niq = iq - 1;

            it.i_quantity = niq;

            db.SaveChanges();
            //Label5.Text = iq.ToString();
            //Label6.Text = niq.ToString();

            Button3.Visible = true;
            Label5.Text     = "Your order place successfully";
            Label6.Text     = "your order id is:" + od.o_id.ToString();
            Button1.Enabled = false;
            Button4.Visible = true;
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string             id1 = TextBox1.Text;
            Database1Entities4 db  = new Database1Entities4();
            User_DB            u1  = db.User_DB.Where(us => (us.u_id == id1)).FirstOrDefault <User_DB>();

            if (u1 == null)
            {
                int ag = System.DateTime.Now.Year - Calendar1.SelectedDate.Year;

                User_DB u = new User_DB();
                u.u_id       = TextBox1.Text;
                u.u_password = TextBox2.Text;
                db.User_DB.Add(u);
                db.SaveChanges();

                Customer c = new Customer();
                c.c_id      = TextBox1.Text;
                c.c_name    = TextBox3.Text;
                c.c_dob     = DateTime.Parse(TextBox4.Text);
                c.c_age     = ag;
                c.c_mail    = TextBox5.Text;
                c.c_address = TextBox6.Text;
                c.c_contact = TextBox7.Text;
                db.Customers.Add(c);
                db.SaveChanges();
                Label8.Text = "register sucessfully";
                // Response.Redirect("~/Login.aspx");
                Button2.Visible = true;
            }
            else
            {
                Label8.Text = "This ID is already taken.Try another one";
            }
        }
コード例 #4
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            string             id1       = TextBox1.Text;
            string             password1 = TextBox2.Text;
            Database1Entities4 db        = new Database1Entities4();
            User_DB            u         = db.User_DB.Where(us => (us.u_id == id1) && (us.u_password == password1)).FirstOrDefault <User_DB>();

            if (u == null)
            {
                Label3.Text = "ID or Password is Incorrect.Try Again!!";
            }
            else
            {
                Admin a = db.Admins.Where(ad => (ad.a_id == id1)).FirstOrDefault <Admin>();
                if (a == null)
                {
                    Label3.Text = "You Are not registerd as Admin";
                }
                else
                {
                    Session["aid"] = id1;
                    Response.Redirect("~/WelcomeAdmin.aspx");
                }
            }
        }
コード例 #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string             id       = TextBox1.Text;
            string             password = TextBox2.Text;
            Database1Entities4 db       = new Database1Entities4();
            User_DB            u        = db.User_DB.Where(us => (us.u_id == id) && (us.u_password == password)).FirstOrDefault <User_DB>();

            if (u == null)
            {
                Label3.Text = "ID or Password is Incorrect.Try Again!!";
            }
            else
            {
                Customer c = db.Customers.Where(cs => (cs.c_id == id)).FirstOrDefault <Customer>();
                if (c == null)
                {
                    Label3.Text = "You are not registered as customer";
                }
                else
                {
                    Session["cid"] = id;
                    Response.Redirect("~/WelcomeCus.aspx");
                }
            }
        }
コード例 #6
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Database1Entities4 db = new Database1Entities4();
            Item_DB            i  = db.Item_DB.Where(it1 => it1.I_id == TextBox1.Text).FirstOrDefault <Item_DB>();

            if (i == null)
            {
                Item_DB it = new Item_DB();
                it.I_id          = TextBox1.Text;
                it.I_name        = TextBox2.Text;
                it.I_description = TextBox3.Text;
                it.cc_id         = TextBox8.Text;
                it.i_cost        = Int32.Parse(TextBox4.Text);
                it.i_discount    = Int32.Parse(TextBox5.Text);
                it.i_status      = TextBox9.Text;
                it.i_quantity    = Int32.Parse(TextBox6.Text);
                it.i_company     = TextBox7.Text;
                it.i_imagepath   = TextBox10.Text;
                db.Item_DB.Add(it);
                db.SaveChanges();

                Label13.Text    = "Item inserted sucessfully";
                Button3.Enabled = true;
                Button4.Enabled = true;
            }
            else
            {
                Label13.Text = "Item ID is already taken for another Item take another one for this";
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            string             cid = Request.QueryString["Customer"];
            Database1Entities4 db  = new Database1Entities4();
            Customer           cs  = db.Customers.Where(c => c.c_id == cid).FirstOrDefault <Customer>();

            if (cs != null)
            {
                Label2.Text = "Welcome " + cs.c_name;
            }
            else
            {
                Response.Redirect("~/Login.aspx");
            }
        }
コード例 #8
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            string             id       = TextBox1.Text;
            string             password = TextBox2.Text;
            Database1Entities4 db       = new Database1Entities4();
            User_DB            u        = db.User_DB.Where(us => (us.u_id == id) && (us.u_password == password)).FirstOrDefault <User_DB>();

            if (u == null)
            {
                Label3.Text = "ID or Password is Incorrect.Try Again!!";
            }
            else
            {
                Session["cid"] = id;
                Response.Redirect("~/Feedback.aspx?Customer=" + id);
            }
        }
コード例 #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["cid"] != null)
     {
         string             cid = Session["cid"].ToString();
         Database1Entities4 db  = new Database1Entities4();
         Customer           cs  = db.Customers.Where(c => c.c_id == cid).FirstOrDefault <Customer>();
         if (cs != null)
         {
             Label1.Text = "Welcome: " + cs.c_name;
         }
         else
         {
             Response.Redirect("~/Home.aspx");
         }
     }
     else
     {
         Response.Redirect("~/Home.aspx");
     }
     // Label2.Text = Session["cid"].ToString();
 }
コード例 #10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string             catid = TextBox1.Text;
            Database1Entities4 db    = new Database1Entities4();
            Category           cat   = db.Categories.Where(c => (c.cc_id == catid)).FirstOrDefault <Category>();

            if (cat == null)
            {
                //Label4.Text = "Id can be used";
                Category category = new Category();
                category.cc_id          = TextBox1.Text;
                category.cc_name        = TextBox2.Text;
                category.cc_description = TextBox3.Text;
                db.Categories.Add(category);
                db.SaveChanges();
                Label4.Text = "category inserted sucessfully";
            }
            else
            {
                Label4.Text = "ID is already taken for another category.Try another one";
            }
        }
コード例 #11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string             cid = Request.QueryString["Customer"];
            Database1Entities4 db  = new Database1Entities4();
            int           oid      = Int32.Parse(TextBox1.Text);
            order_details od       = db.order_details.Where(o => (o.o_id == oid) && (o.c_id == cid)).FirstOrDefault <order_details>();

            if (od == null)
            {
                Label1.Text = "Can't find any order.Try Again!!";
            }
            else
            {
                Feedback_DB fb = new Feedback_DB();
                fb.c_id     = od.c_id;
                fb.i_id     = od.i_id;
                fb.feedback = TextBox2.Text;
                db.Feedback_DB.Add(fb);
                db.SaveChanges();

                Label1.Text     = od.c_id + " Your feedback send sucessfully";
                Button2.Enabled = true;
            }
        }