protected void Button1_Click(object sender, EventArgs e) { try{ DataTable x = new DataTable(); string sql = "select top 1 id_thuong_hieu + 1 from thuong_hieu order by id_thuong_hieu desc "; System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); System.Data.SqlClient.SqlCommand lenh = new System.Data.SqlClient.SqlCommand(sql, ketnoi); ketnoi.Open(); System.Data.SqlClient.SqlDataAdapter data = new System.Data.SqlClient.SqlDataAdapter(lenh); data.Fill(x); ketnoi.Close(); SqlConnection connDB = new SqlConnection(connect.getconnect()); SqlCommand cmd = new SqlCommand("thuong_hieu_them", connDB); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_thuong_hieu", SqlDbType.NVarChar).Value = x.Rows[0][0]; cmd.Parameters.Add("@ten_thuong_hieu", SqlDbType.NVarChar).Value = mH.Base64Encode(TextBox1.Text); cmd.Parameters.Add("@anh_thuong_hieu", SqlDbType.NVarChar).Value = mH.Base64Encode(TextBox2.Text); connDB.Open(); cmd.ExecuteNonQuery(); connDB.Close(); Response.Write("<script language='javascript'> alert('Thêm thành công'); window.open('danhSach.aspx','_self', 1); </script>"); } catch (Exception x) { Response.Write("<script language='javascript'> alert('thêm bị lỗi!');history.go(-1); </script>"); } }
protected void Button1_Click(object sender, EventArgs e) { // try { DataTable x = new DataTable(); string sql = "select top 1 id_loai_san_pham + 1 from loai_san_pham order by id_loai_san_pham desc "; System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect()); System.Data.SqlClient.SqlCommand lenh = new System.Data.SqlClient.SqlCommand(sql, ketnoi); ketnoi.Open(); System.Data.SqlClient.SqlDataAdapter data = new System.Data.SqlClient.SqlDataAdapter(lenh); data.Fill(x); ketnoi.Close(); string ten_loai_san_pham = mH.Base64Encode(TextBox1.Text); string anh_loai_san_pham = TextBox2.Text; string bieu_tuong_loai_san_pham = TextBox3.Text; string cap_do_loai_san_pham = (TextBox4.Text); string id_cha_loai_san_pham = DropDownList1.SelectedValue; // SqlConnection connDB = new SqlConnection(connect.getconnect()); SqlCommand cmd = new SqlCommand("loai_san_pham_them", connDB); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_loai_san_pham", SqlDbType.NVarChar).Value = x.Rows[0][0]; cmd.Parameters.Add("@ten_loai_san_pham", SqlDbType.NVarChar).Value = ten_loai_san_pham; cmd.Parameters.Add("@anh_loai_san_pham", SqlDbType.NVarChar).Value = anh_loai_san_pham; cmd.Parameters.Add("@bieu_tuong_loai_san_pham", SqlDbType.NVarChar).Value = bieu_tuong_loai_san_pham; cmd.Parameters.Add("@cap_do_loai_san_pham", SqlDbType.NVarChar).Value = cap_do_loai_san_pham; cmd.Parameters.Add("@id_cha_loai_san_pham", SqlDbType.NVarChar).Value = id_cha_loai_san_pham; connDB.Open(); cmd.ExecuteNonQuery(); connDB.Close(); Response.Write("<script language='javascript'> alert('Thêm thành công'); window.open('danhsachloaisanpham.aspx','_self', 1); </script>"); } catch (Exception x) { Response.Write("<script language='javascript'> alert('Thêm bị lỗi!'); history.go(-1); </script>"); } }
protected void Button1_Click(object sender, EventArgs e) { int id_san_pham = 0; try { if (Request.QueryString["id_san_pham"] != null && Request.QueryString["id_san_pham"] != "") { id_san_pham = int.Parse(Request.QueryString["id_san_pham"]); } } catch (Exception a) { } if (id_san_pham == 0) { Response.Redirect("./danhSach.aspx"); } { string loi = "Thêm bị lỗi"; try { WebApplication2.QuanTri.maHoa mH = new WebApplication2.QuanTri.maHoa(); WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect(); System.Data.SqlClient.SqlConnection connDB = new System.Data.SqlClient.SqlConnection(connect.getconnect()); System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("danh_sach_anh_cua_san_pha_them", connDB); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add("@id_san_pham", System.Data.SqlDbType.NVarChar).Value = id_san_pham; cmd.Parameters.Add("@duong_link_anh", System.Data.SqlDbType.NVarChar).Value = mH.Base64Encode(TextBox1.Text); connDB.Open(); cmd.ExecuteNonQuery(); connDB.Close(); Response.Write("<script language='javascript'> alert('Thêm thành công'); window.open('" + Session["danhSachAnh"].ToString() + "','_self', 1); </script>"); } catch (Exception x) { Response.Write("<script language='javascript'> alert('" + loi + "');history.go(-1); </script>"); } } }
protected void Button1_Click(object sender, EventArgs e) { try{ SqlConnection connDB = new SqlConnection(connect.getconnect()); SqlCommand cmd = new SqlCommand("thuong_hieu_sua", connDB); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_thuong_hieu", SqlDbType.NVarChar).Value = id_thuong_hieu; if (TextBox1.Text == null || TextBox1.Text == "") { cmd.Parameters.Add("@ten_thuong_hieu", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@ten_thuong_hieu", SqlDbType.NVarChar).Value = mH.Base64Encode(TextBox1.Text); } if (TextBox2.Text == null || TextBox2.Text == "") { cmd.Parameters.Add("@anh_thuong_hieu", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@anh_thuong_hieu", SqlDbType.NVarChar).Value = mH.Base64Encode(TextBox2.Text); } connDB.Open(); cmd.ExecuteNonQuery(); connDB.Close(); Response.Write("<script language='javascript'> alert('sửa thành công');window.open('danhSach.aspx','_self', 1); </script>"); } catch (Exception x) { Response.Write("<script language='javascript'> alert('sửa bị lỗi, Vì liên kết bảng!'); history.go(-1); </script>"); } }
protected void Button1_Click(object sender, EventArgs e) { try{ string ten_loai_san_pham = mH.Base64Encode(TextBox1.Text); string anh_loai_san_pham = null; if (TextBox2.Text != null) { anh_loai_san_pham = TextBox2.Text; } string bieu_tuong_loai_san_pham = null; if (TextBox2.Text != null) { bieu_tuong_loai_san_pham = TextBox3.Text; } string cap_do_loai_san_pham = null; if (TextBox4.Text != null) { cap_do_loai_san_pham = (TextBox4.Text); } string id_cha_loai_san_pham = DropDownList1.SelectedValue; // SqlConnection connDB = new SqlConnection(connect.getconnect()); SqlCommand cmd = new SqlCommand("loai_san_pham_sua_thanh_phan", connDB); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_loai_san_pham", SqlDbType.NVarChar).Value = id_loai_san_pham; if (ten_loai_san_pham == null || ten_loai_san_pham == "") { cmd.Parameters.Add("@ten_loai_san_pham", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@ten_loai_san_pham", SqlDbType.NVarChar).Value = ten_loai_san_pham; } if (anh_loai_san_pham == null || anh_loai_san_pham == "") { cmd.Parameters.Add("@anh_loai_san_pham", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@anh_loai_san_pham", SqlDbType.NVarChar).Value = anh_loai_san_pham; } if (bieu_tuong_loai_san_pham == null || bieu_tuong_loai_san_pham == "") { cmd.Parameters.Add("@bieu_tuong_loai_san_pham", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@bieu_tuong_loai_san_pham", SqlDbType.NVarChar).Value = bieu_tuong_loai_san_pham; } if (cap_do_loai_san_pham == null || cap_do_loai_san_pham == "") { cmd.Parameters.Add("@cap_do_loai_san_pham", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@cap_do_loai_san_pham", SqlDbType.NVarChar).Value = cap_do_loai_san_pham; } if (id_cha_loai_san_pham == null || id_cha_loai_san_pham == "") { cmd.Parameters.Add("@id_cha_loai_san_pham", SqlDbType.NVarChar).Value = DBNull.Value; } else { cmd.Parameters.Add("@id_cha_loai_san_pham", SqlDbType.NVarChar).Value = id_cha_loai_san_pham; } connDB.Open(); cmd.ExecuteNonQuery(); connDB.Close(); Response.Write("<script language='javascript'> alert('sửa thành công'); window.open('" + Session["LoaiSanPham"].ToString() + "','_self', 1); </script>"); } catch (Exception x) { Response.Write("<script language='javascript'> alert('sửa bị lỗi, Vì liên kết bảng!'); history.go(-1); </script>"); } }