protected void btn_change_Click(object sender, EventArgs e) { if (Session["id"].ToString() != null) { SqlCommand cmd = new SqlCommand("select * from Customer where cust_id=@id and cust_pass=@pass"); cmd.Parameters.AddWithValue("@id", int.Parse(Session["id"].ToString())); cmd.Parameters.AddWithValue("@pass", int.Parse(txt_old_pass.Text)); DataTable dt = DBlayer.Sel(cmd); if (dt.Rows.Count > 0) { cmd = new SqlCommand("update Customer set Cust_pass=@newp where Cust_id=@id and Cust_pass=@oldp"); cmd.Parameters.AddWithValue("@id", int.Parse(Session["id"].ToString())); cmd.Parameters.AddWithValue("oldp", int.Parse(dt.Rows[0]["cust_pass"].ToString())); cmd.Parameters.AddWithValue("newp", int.Parse(txt_new_pass.Text)); if (DBlayer.Dml(cmd) > 0) { lbl_status.ForeColor = System.Drawing.Color.Green; lbl_status.Text = "password changed ^_^"; } else { lbl_status.Text = "enter data Again"; } } else { lbl_status.ForeColor = System.Drawing.Color.Red; lbl_status.Text = "Wrong Password"; } } }
protected void lbtn_forget_Click(object sender, EventArgs e) { if (txt_name.Text != "") { SqlCommand c = new SqlCommand("select cust_pass,cust_mail from customer where cust_username = @mail"); c.Parameters.AddWithValue("@mail", txt_name.Text); DataTable d = DBlayer.Sel(c); if (d.Rows.Count > 0) { MailMessage msg = new MailMessage(); msg.To.Add(d.Rows[0]["cust_mail"].ToString()); msg.From = new MailAddress("*****@*****.**"); msg.Subject = "recover your mail"; msg.Body = "this is your password: "******"cust_pass"].ToString(); SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 25; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "01226783114"); smtp.EnableSsl = true; smtp.Send(msg); lbl_mail_stutes.Text = " message sent succesfully"; } } }
protected void Page_Load(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("SELECT p1.* FROM Product p1 LEFT JOIN Product p2 ON (p1.Category_id = p2.Category_id AND p1.Prod_id < p2.Prod_id) WHERE p2.Prod_id IS NULL"); datalist_home.DataSource = DBlayer.Sel(cmd); datalist_home.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { // GitHub Test 000 SqlCommand cmd = new SqlCommand("SELECT top(1) p1.* FROM Product p1 LEFT JOIN Product p2 ON (p1.Category_id = p2.Category_id AND p1.Prod_id < p2.Prod_id) WHERE p2.Prod_id IS NULL order by p1.Category_id desc"); dlst_latest.DataSource = DBlayer.Sel(cmd); dlst_latest.DataBind(); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void btn_log_Click(object sender, EventArgs e) { try { if (txt_name.Text != "" && txt_pass.Text != "") { SqlCommand cmd = new SqlCommand("select cust_Id ,isadmin from customer where cust_username=@username and cust_pass=@pass "); cmd.Parameters.AddWithValue("@username", txt_name.Text); cmd.Parameters.AddWithValue("@pass", txt_pass.Text); DataTable dt = DBlayer.Sel(cmd); if (dt.Rows.Count != 0) { MultiView1.ActiveViewIndex = 1; Session.Add("id", dt.Rows[0][0].ToString()); Session.Add("isadmin", int.Parse(dt.Rows[0][1].ToString())); if (ch_rem.Checked) { HttpCookie co = new HttpCookie("log"); co.Expires = DateTime.Now.AddDays(10); co.Values.Add("id", dt.Rows[0][0].ToString()); co.Values.Add("isadmin", dt.Rows[0][1].ToString()); Response.Cookies.Add(co); } if (int.Parse(Session["isadmin"].ToString()) == 1) { Response.Redirect("~/Admin/HomeAdmin.aspx", false); } else { Response.Redirect("~/Annonymous/Home.aspx", false); } } else { lbl_msg.Text = "invalid UserName or Password"; } } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void gv_history_show_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = (int)gv_history_show.DataKeys[e.RowIndex].Value; cmd = new SqlCommand("delete from [OrderItem] where order_id=@id"); cmd.Parameters.AddWithValue("@id", id); DBlayer.Dml(cmd); cmd = new SqlCommand("delete from [order] where order_id=@id"); cmd.Parameters.AddWithValue("@id", id); DBlayer.Dml(cmd); cmd = new SqlCommand("SELECT Order_id, state, Packing_Date, Deliver_Date FROM[Order] where Cust_id =@id"); cmd.Parameters.AddWithValue("@id", int.Parse(Session["id"].ToString())); dt = DBlayer.Sel(cmd); gv_history_show.DataSource = dt; gv_history_show.DataBind(); for (int i = 0; i < gv_history_show.Rows.Count; i++) { string state = ((Label)gv_history_show.Rows[i].FindControl("lbl_state")).Text; LinkButton btn = (LinkButton)gv_history_show.Rows[i].FindControl("lbl_delete"); if (state == "pending") { btn.Visible = true; } else { btn.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["log"] != null) { Session.Add("id", Request.Cookies["log"].Values["id"]); MultiView1.ActiveViewIndex = 1; } if (Session["id"] != null) { try { SqlCommand cmd = new SqlCommand("select cust_username from customer where cust_Id = @id"); cmd.Parameters.AddWithValue("@id", Session["id"].ToString()); DataTable dt = DBlayer.Sel(cmd); lbl_name.Text = dt.Rows[0]["cust_username"].ToString(); MultiView1.ActiveViewIndex = 1; } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["isadmin"] != null) { if (int.Parse(Session["isadmin"].ToString()) == 1) { Response.Redirect("~/Admin/HomeAdmin.aspx"); } } if (Session["id"] != null) { cmd = new SqlCommand("SELECT Order_id, state, Packing_Date, Deliver_Date FROM[Order] where Cust_id =@id"); cmd.Parameters.AddWithValue("@id", int.Parse(Session["id"].ToString())); dt = DBlayer.Sel(cmd); gv_history_show.DataSource = dt; gv_history_show.DataBind(); for (int i = 0; i < gv_history_show.Rows.Count; i++) { string state = ((Label)gv_history_show.Rows[i].FindControl("lbl_state")).Text; LinkButton btn = (LinkButton)gv_history_show.Rows[i].FindControl("lbl_delete"); if (state == "pending") { btn.Visible = true; } else { btn.Visible = false; } } } else { Response.Redirect("~/Annonymous/Home.aspx"); } }