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 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; } } }