protected void btnSave_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); if (btnSave.Text == "Save") { //add new ObjectParameter objParam = new ObjectParameter("ProductID", typeof(int)); mdb.Insert_Product(txtProductName.Text, Convert.ToDouble(txtPrice.Text), txtManufacturer.Text, txtfeatures.Text, txtdescription.Text, Convert.ToInt32(DRLcategory.SelectedValue.ToString()), objParam); FileUpload1.SaveAs(Server.MapPath(@"pics\product\") + objParam.Value.ToString() + ".jpg"); lblmsg.Text = "Product Added Successfuly"; MultiView1.ActiveViewIndex = 0; } else { //update product mdb.Update_Product(txtProductName.Text, Convert.ToDouble(txtPrice.Text), txtManufacturer.Text, txtfeatures.Text, txtdescription.Text, Convert.ToInt32(productID.Value)); lblmsg.Text = "Product Updated Successfuly"; GridView1.DataSource = null; GridView1.DataBind(); GridView1.SelectedIndex = -1; btnEdit.Enabled = false; btnDelete.Enabled = false; MultiView1.ActiveViewIndex = 0; } }
protected void Button1_Click(object sender, EventArgs e) { if (IsPostBack) { MydbEntities mdb = new MydbEntities(); DataTable dt = new DataTable(); dt.Columns.Add("Orddate"); dt.Columns.Add("ordprice"); var myrep = mdb.Get_monthly_Report(Calendar1.SelectedDate.Month.ToString()); foreach (var x in myrep) { DataRow r = dt.NewRow(); r[0] = x.ordDate.Value.ToShortDateString(); r[1] = x.total.Value.ToString(); dt.Rows.Add(r); } double sum = 0; Chart1.Series.Add("test"); Chart1.Series["test"].XValueMember = "Orddate"; Chart1.Series["test"].YValueMembers = "ordprice"; Chart1.DataSource = dt; Chart1.DataBind(); Chart1.Visible = true; for (int i = 0; i < dt.Rows.Count - 1; i++) { sum = sum + Convert.ToDouble(dt.Rows[i][1].ToString()); } lblresult.Text = "Total sales in month : " + Calendar1.SelectedDate.Month.ToString() + " is " + sum.ToString() + "$"; } }
protected void Button2_Click(object sender, EventArgs e) { Utility u = new Utility(); if (u.ReadFromCookie("bike_login", "Bike_user", Request) != null) { int UID = Convert.ToInt32(u.ReadFromCookie("bike_login", "Bike_user", Request).ToString()); string pass = u.ReadFromCookie("bike_login", "Pass", Request).ToString(); if (pass.ToString() == txtoldpwd.Text) { MydbEntities mdb = new MydbEntities(); mdb.Update_Customer_PWD(UID, txtnewpwd.Text); u.Removecookie("bike_login", Response); Session["Mybikecart"] = null; Response.Redirect("Default.aspx"); } else { lblmsg.Text = "old password not correct!"; } } else { Response.Redirect("Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { Utility u = new Utility(); if (u.ReadFromCookie("bike_login", "Bike_user", Request) != null) { int UID = Convert.ToInt32(u.ReadFromCookie("bike_login", "Bike_user", Request).ToString()); MydbEntities mdb = new MydbEntities(); var customer = from c in mdb.Customers where c.CustomerID == UID select c.Is_Admin; if (customer.Any()) { foreach (var x in customer) { if (x == false) { Response.Redirect(@"Default.aspx"); } } } } else { Response.Redirect(@"Default.aspx"); } }
protected void LinkButton28_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); var category = from c in mdb.Categories select new { c.CategoryID, c.CategoryName }; DataList1.DataSource = category.ToList(); DataList1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); double myrep = Convert.ToDouble((from r in mdb.OrdersDetails where r.Order.ordDate == Calendar1.SelectedDate select r.ProductPrice).Sum()); lblresult.Text = "Total sales in : " + Calendar1.SelectedDate.ToShortDateString() + " is : " + myrep.ToString() + "$"; }
protected void LinkButton28_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products select new { p.ProductID, p.ProductName, p.ProductPrice }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); }
public void sortcategory(string mystr) { MydbEntities mdb = new MydbEntities(); var category = from c in mdb.Categories where c.CategoryName.StartsWith(mystr) select new { c.CategoryID, c.CategoryName }; DataList1.DataSource = category.ToList(); DataList1.DataBind(); }
protected void btnAddRate_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); pnladdrate.Visible = false; pnlAfterAdd.Visible = true; mdb.Insert_Rate(Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(prdID.Value)); fillratedata(Convert.ToInt32(prdID.Value)); }
protected void Page_Load(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products select new { p.ProductID, p.ProductName, p.Category.CategoryName }; DataList1.DataSource = products.ToList(); DataList1.DataKeyField = "ProductID"; DataList1.DataBind(); }
public void sortprogram(string mystr) { MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products where p.ProductName.StartsWith(mystr) select new { p.ProductID, p.ProductName, p.ProductPrice }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); }
protected void btn_addcomment_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); Utility u = new Utility(); string customerid = u.ReadFromCookie("bike_login", "Bike_user", Request).ToString(); mdb.Insert_Comment(txt_entercomment.Text, Convert.ToInt32(customerid), Convert.ToInt32(prdID.Value)); fiilcommentdata(Convert.ToInt32(prdID.Value)); txt_entercomment.Text = string.Empty; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products select new { p.ProductID, p.ProductName, p.ProductPrice }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); } }
public void sortprogram(string mystr) { int id = Convert.ToInt32(Request.QueryString[0].ToString()); MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products where p.CategoryID == id && p.ProductName.StartsWith(mystr) select new { p.ProductID, p.ProductName, p.ProductPrice }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); }
protected void LinkButton28_Click(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString[0].ToString()); MydbEntities mdb = new MydbEntities(); var products = from p in mdb.Products where p.CategoryID == id select new { p.ProductID, p.ProductName, p.ProductPrice }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); }
public string GetLastID() { MydbEntities mdb = new MydbEntities(); Order lastid = (from lid in mdb.Orders orderby lid.OrderID descending select lid).First(); string ordid = new string(lastid.OrderID.ToString().Where(char.IsDigit).ToArray()); ordid = "SO" + (Convert.ToInt32(ordid) + 1).ToString(); return(ordid); }
protected void Page_Load(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); if (!IsPostBack) { var products = from p in mdb.Products select p.ProductName; productlist.DataSource = products.ToList(); productlist.DataBind(); } }
protected void btnDelete_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); mdb.Delete_Product(Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text)); lblmsg.Text = "Product Deleted Successfuly"; GridView1.DataSource = null; GridView1.DataBind(); GridView1.SelectedIndex = -1; btnEdit.Enabled = false; btnDelete.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); if (!IsPostBack) { var category = from c in mdb.Categories select new { c.CategoryID, c.CategoryName }; DataList1.DataSource = category.ToList(); DataList1.DataBind(); } }
protected void LinkButton1_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); string ordid = GetLastID(); mdb.Insert_Order(ordid, Convert.ToInt32(txtusername.Text), DateTime.Now); for (int i = 0; i < GridView1.Rows.Count; i++) { mdb.Insert_OrdersDetails(ordid, Convert.ToInt32(GridView1.Rows[i].Cells[0].Text.ToString()), Convert.ToDouble(GridView1.Rows[i].Cells[2].Text.ToString())); } Session["MyBikecart"] = null; Response.Redirect(@"./thanks.aspx"); }
void fiilcommentdata(int id) { MydbEntities mdb = new MydbEntities(); var comments = from c in mdb.Comments where c.ProductID == id select new { c.CommentText, c.Customer.FirstName }; if (comments.Any()) { ListView1.DataSource = comments.ToList(); ListView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MydbEntities mdb = new MydbEntities(); var categories = from c in mdb.Categories select new { c.CategoryID, c.CategoryName }; DRLcategory.DataSource = categories.ToList(); DRLcategory.DataTextField = "CategoryName"; DRLcategory.DataValueField = "CategoryID"; DRLcategory.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); var customerusername = from c in mdb.Customers where c.UserName == txtUserName.Text select c.UserName; if (customerusername.Any()) { lblmsg.Text = "UserName Already Exists"; } else { mdb.Insert_Customer(txtUserName.Text, txtPWD.Text, txtFirstName.Text, txtlastName.Text, DRLMaritalst.SelectedValue, RBLGender.SelectedValue, Convert.ToDouble(txtIncome.Text), Convert.ToDouble(txtChildren.Text), DRLeducation.SelectedValue, DRLOccupation.SelectedValue, RBLHomeOwner.SelectedValue, Convert.ToDouble(txtcar.Text), DRLCommuteD.SelectedValue, DRLRegion.SelectedValue, Convert.ToDouble(txtAge.Text), "No", false); lblmsg.Text = "Register Done"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MydbEntities mdb = new MydbEntities(); var category = from c in mdb.Categories select new { c.CategoryID, c.CategoryName }; DRPCategory.DataSource = category.ToList(); DRPCategory.DataValueField = "CategoryID"; DRPCategory.DataTextField = "CategoryName"; DRPCategory.DataBind(); DRPCategory.Items.Add("All Categories"); DRPCategory.SelectedIndex = DRPCategory.Items.IndexOf(DRPCategory.Items.FindByText("All Categories")); } }
protected void Button1_Click(object sender, EventArgs e) { lblmsg.Text = ""; GridView1.DataSource = null; GridView1.DataBind(); GridView1.SelectedIndex = -1; btnEdit.Enabled = false; btnDelete.Enabled = false; MydbEntities mdb = new MydbEntities(); var category = from c in mdb.Categories where c.CategoryName.Contains(txtSearch.Text) select new { c.CategoryID, c.CategoryName }; GridView1.DataSource = category.ToList(); GridView1.DataBind(); if (!category.Any()) { lblmsg.Text = "No Result!"; } }
protected void Button1_Click(object sender, EventArgs e) { lblmsg.Text = ""; GridView1.DataSource = null; GridView1.DataBind(); GridView1.SelectedIndex = -1; btnEdit.Enabled = false; btnDelete.Enabled = false; MydbEntities mdb = new MydbEntities(); var product = from p in mdb.Products where p.ProductName.Contains(txtsearch.Text) select new { p.ProductID, p.ProductName, p.ProductPrice, p.Manufacturer, p.Features, p.Description, p.Category.CategoryName }; GridView1.DataSource = product.ToList(); GridView1.DataBind(); if (!product.Any()) { lblmsg.Text = "No Result!"; } }
protected void Button1_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); if (DRPCategory.SelectedItem.ToString() == "All Categories") { var products = from p in mdb.Products where p.ProductName.Contains(txtproductname.Text) select new { p.ProductID, p.ProductName }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); } else { var products = from p in mdb.Products where p.ProductName.Contains(txtproductname.Text) && p.CategoryID == DRPCategory.SelectedIndex select new { p.ProductID, p.ProductName }; DataList1.DataSource = products.ToList(); DataList1.DataBind(); } }
void fillproducrdata(int id) { MydbEntities mdb = new MydbEntities(); if (!IsPostBack) { var productdetails = from p in mdb.Products where p.ProductID == id select new { p.ProductID, p.ProductName, p.ProductPrice, p.Manufacturer, p.Description, p.Features, p.Category.CategoryName }; foreach (var x in productdetails) { lblproductname.Text = x.ProductName; lblProductPrice.Text = x.ProductPrice.ToString(); lblManufacturer.Text = x.Manufacturer; lblFeatures.Text = x.Features; lblDescription.Text = x.Description; lblCategoryName.Text = x.CategoryName; prdID.Value = x.ProductID.ToString(); Image1.ImageUrl = "../pics/product/" + x.ProductID.ToString() + ".jpg"; } } }
protected void btnSave_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); if (btnSave.Text == "Save") { //Add new ObjectParameter objParam = new ObjectParameter("CategoryID", typeof(int)); mdb.Insert_Category(txtcatName.Text, objParam); FileUpload1.SaveAs(Server.MapPath(@"pics\category\") + objParam.Value.ToString() + ".jpg"); lblmsg.Text = "Category Added Successfuly"; MultiView1.ActiveViewIndex = 0; } else { // Update Category mdb.Update_Category(txtcatName.Text, Convert.ToInt32(catid.Value)); GridView1.DataSource = null; GridView1.DataBind(); GridView1.SelectedIndex = -1; lblmsg.Text = "Category Updated Successfuly"; MultiView1.ActiveViewIndex = 0; } }
protected void Button1_Click(object sender, EventArgs e) { MydbEntities mdb = new MydbEntities(); Utility u = new Utility(); var customer = from c in mdb.Customers where c.UserName == txtUserName.Text && c.PWD == txtPWD.Text select new { c.Is_Admin, c.CustomerID }; string cusid = ""; if (customer.Any()) { // Create cookie foreach (var c in customer) { cusid = c.CustomerID.ToString(); } u.Createcookie("bike_login", new string[] { "Bike_user", "Pass" }, new string[] { cusid, txtPWD.Text }, true, Response); lblmsg.Text = "Welcome Back " + u.ReadFromCookie("bike_login", "Bike_user", Request); foreach (var x in customer) { if (x.Is_Admin == false) { MultiView1.ActiveViewIndex = 1; } else { MultiView1.ActiveViewIndex = 2; } } Page.Response.Redirect(Page.Request.Url.ToString(), true); } else { lblmsg.Text = "Login Error"; } }