Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id_thuong_hieu = -1;
            int xoa            = 0;

            try
            {
                if (Request.QueryString["xoa"] != null && Request.QueryString["xoa"] != "")
                {
                    id_thuong_hieu = int.Parse(Request.QueryString["xoa"]);
                    xoa            = 1;
                }
            }
            catch (Exception qqe) { }
            if (id_thuong_hieu != -1 && xoa == 1)
            {
                try {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("thuong_hieu_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_thuong_hieu", SqlDbType.NVarChar).Value = id_thuong_hieu;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Xóa thành công'); window.open(document.referrer,'_self', 1);</script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('Xóa bị lỗi! Liên kết với sẩn phẩm');history.go(-1); </script>");
                }
            }
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                int id_giam_gia = 0;
                int id_san_pham = 0;
                id_giam_gia = int.Parse(Request.QueryString["id_giam_gia"]);
                id_san_pham = int.Parse(Request.QueryString["id_san_pham"]);

                WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                SqlConnection connDB = new SqlConnection(connect.getconnect());
                SqlCommand    cmd    = new SqlCommand("danh_sac_san_pham_giam_gia_them", connDB);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id_san_pham", SqlDbType.NVarChar).Value    = id_san_pham;
                cmd.Parameters.Add("@id_giam_gia", SqlDbType.NVarChar).Value    = id_giam_gia;
                cmd.Parameters.Add("@phan_tram_giam", SqlDbType.NVarChar).Value = TextBox2.Text;
                cmd.Parameters.Add("@giam_toi_da", SqlDbType.NVarChar).Value    = TextBox3.Text;
                connDB.Open();
                cmd.ExecuteNonQuery();
                connDB.Close();
                Response.Write("<script language='javascript'> alert('Thêm thành công');  window.open('" + Session["GiamGia"].ToString() + "','_self', 1);</script>");
            }
            catch (Exception x)
            {
                Response.Write("<script language='javascript'> alert('Thêm bị lỗi!'); history.go(-1); </script>");
            }
        }
Пример #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         int id_giam_gia = 0;
         int id_san_pham = 0;
         id_giam_gia = int.Parse(Request.QueryString["id_giam_gia"]);
         id_san_pham = int.Parse(Request.QueryString["id_san_pham"]);
         string sql = "select id_san_pham, id_giam_gia, phan_tram_giam, cast(giam_toi_da as int) from danh_sac_san_pham_giam_gia where id_giam_gia=" + id_giam_gia + " and id_san_pham=" + id_san_pham;
         WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
         System.Data.DataTable ds = new System.Data.DataTable();
         System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
         new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
         if (ds == null || ds.Rows.Count == 0)
         {
             int.Parse("a");
         }
         if (!IsPostBack)
         {
             TextBox2.Text = ds.Rows[0][2].ToString();
             TextBox3.Text = ds.Rows[0][3].ToString();
         }
     }
     catch (Exception a)
     {
         Response.Write("<script language='javascript'> alert('Đã xảy ra lỗi');history.go(-1); </script>");
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["GiamGia"] = HttpContext.Current.Request.Url.AbsoluteUri;
            try { Session["GiamGia"] = WebApplication2.QuanTri.maHoa.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "xoa"); }
            catch (Exception a) { }
            int id_giam_gia = -1;
            int xoa         = 0;

            try
            {
                if (Request.QueryString["xoa"] != null && Request.QueryString["xoa"] != "")
                {
                    id_giam_gia = int.Parse(Request.QueryString["xoa"]);
                    xoa         = 1;
                }
            }
            catch (Exception qqe) { }
            if (id_giam_gia != -1 && xoa == 1)
            {
                string loi = "Xóa bị lỗi! Liên kết với sẩn phẩm";
                try
                {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    string sql =
                        "select CASE    WHEN DATEDIFF(MINUTE, GETDATE(),thoi_diem_ket_thuc_giam_gia)>0 THEN 1    ELSE 0  END from giam_gia where id_giam_gia=" + id_giam_gia;
                    DataTable ds = new DataTable();
                    System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    if (int.Parse(ds.Rows[0][0].ToString()) == 0)
                    {
                        loi = "Không thể xóa! Chương trình giảm giá này đã diễn ra! tốt đẹp!";
                        int.Parse("a");
                    }
                    //
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("giam_gia_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_giam_gia", SqlDbType.NVarChar).Value = id_giam_gia;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Thành công'); window.open('" + Session["GiamGia"].ToString() + "','_self', 1); </script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('" + loi + "');history.go(-1); </script>");
                }
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["PhieuNhap"] = HttpContext.Current.Request.Url.AbsoluteUri;
            try { Session["PhieuNhap"] = WebApplication2.QuanTri.maHoa.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "xoa"); }
            catch (Exception a) { }
            int id_phieu_nhap = -1;
            int xoa           = 0;

            try
            {
                if (Request.QueryString["xoa"] != null && Request.QueryString["xoa"] != "")
                {
                    id_phieu_nhap = int.Parse(Request.QueryString["xoa"]);
                    xoa           = 1;
                }
            }
            catch (Exception qqe) { }
            if (id_phieu_nhap != -1 && xoa == 1)
            {
                string loi = "Xóa bị lỗi! Liên kết với sẩn phẩm";
                try
                {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    string sql =
                        "select CASE    WHEN DATEDIFF(HOUR, GETDATE(),ngay_tao_phieu)>-24 THEN 1    ELSE 0  END from phieu_nhap_hang_hoa where id_phieu_nhap=" + id_phieu_nhap;
                    DataTable ds = new DataTable();
                    System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    if (int.Parse(ds.Rows[0][0].ToString()) == 0)
                    {
                        loi = "Không thể xóa!Vì đã sau 24 giờ kể từ lúc tạo phiếu nhập!";
                        int.Parse("a");
                    }
                    //
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("phieu_nhap_hang_hoa_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_phieu_nhap", SqlDbType.NVarChar).Value = id_phieu_nhap;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Xóa thành công'); window.open('" + Session["PhieuNhap"].ToString() + "','_self', 1); </script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('" + loi + "');history.go(-1); </script>");
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id_kho_hang = -1;

            try
            {
                if (Request.QueryString["id_kho_hang"] != null && Request.QueryString["id_kho_hang"] != "")
                {
                    id_kho_hang = int.Parse(Request.QueryString["id_kho_hang"]);
                }
            }
            catch (Exception qqe) { }
            if (id_kho_hang != -1)
            {
                string loi = "Xóa bị lỗi! Liên kết với sẩn phẩm";
                try
                {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    string sql =
                        "select * from kho_hang where id_kho_hang=" + id_kho_hang;
                    DataTable ds = new DataTable();
                    System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    if (ds.Rows.Count == 0)
                    {
                        loi = "Không thể xóa! Vì lỗi ID kho hàng";
                        int.Parse("a");
                    }
                    //
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("kho_hang_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_kho_hang", SqlDbType.NVarChar).Value = id_kho_hang;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Xóa thành công'); window.open('" + Session["KhoHang"].ToString() + "','_self', 1); </script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('" + loi + "');history.go(-1); </script>");
                }
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int xoa         = 0;
            int id_giam_gia = 0;
            int id_san_pham = 0;

            try
            {
                if (Request.QueryString["id_giam_gia"] != null && Request.QueryString["id_giam_gia"] != "")
                {
                    id_giam_gia = int.Parse(Request.QueryString["id_giam_gia"]);
                }
                if (Request.QueryString["id_san_pham"] != null && Request.QueryString["id_san_pham"] != "")
                {
                    id_san_pham = int.Parse(Request.QueryString["id_san_pham"]);
                }
                if (Request.QueryString["xoa"] != null && Request.QueryString["xoa"] != "")
                {
                    xoa = int.Parse(Request.QueryString["xoa"]);
                }
            }
            catch (Exception a) { }

            if (xoa != 0 && id_giam_gia != 0 && id_san_pham != 0)
            {
                try
                {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("danh_sac_san_pham_giam_gia_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_giam_gia", SqlDbType.NVarChar).Value = id_giam_gia;
                    cmd.Parameters.Add("@id_san_pham", SqlDbType.NVarChar).Value = id_san_pham;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Xóa thành công'); window.open(document.referrer,'_self', 1);</script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('Xóa bị lỗi!');history.go(-1); </script>");
                }
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["id_phieu_nhap"] != null && Request.QueryString["id_phieu_nhap"] != "")
                {
                    id_phieu_nhap = int.Parse(Request.QueryString["id_phieu_nhap"]);
                }
                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) { }

            WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
            string sql =
                " select so_luong_nhap " +
                " from chi_tiet_phieu_nhap " +
                " where id_phieu_nhap=" + id_phieu_nhap + " and id_san_pham=" + id_san_pham;

            System.Data.DataTable ds = new System.Data.DataTable();
            System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
            new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
            so_luong_nhap = int.Parse(ds.Rows[0][0].ToString());

            sql = "select cast(gia_nhap_san_pham as int) " +
                  "from san_pham " +
                  "where id_san_pham=" + id_san_pham;
            ds     = new System.Data.DataTable();
            ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
            new SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);

            if (!IsPostBack)
            {
                TextBox2.Text = so_luong_nhap + "";
                TextBox3.Text = ds.Rows[0][0].ToString();
            }
        }
Пример #9
0
        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>");
                }
            }
        }
Пример #10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string loi = "không sửa được!";

            try
            {
                int    sl_kho = 0, khoan = 0, stt = 0, id_kho = 0;
                string sql = "select id_kho_hang " +
                             "from phieu_nhap_hang_hoa " +
                             "where  id_phieu_nhap=" + id_phieu_nhap;
                WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                System.Data.DataTable ds = new System.Data.DataTable();
                System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                id_kho = int.Parse(ds.Rows[0][0].ToString());

                sql = "select so_luong " +
                      "from chi_tiet_kho_hang " +
                      "where id_kho_hang=" + id_kho + " and id_san_pham=" + id_san_pham;
                ds = new System.Data.DataTable();
                new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                sl_kho = int.Parse(ds.Rows[0][0].ToString());

                if (so_luong_nhap > int.Parse(TextBox2.Text))
                {
                    khoan = so_luong_nhap - int.Parse(TextBox2.Text);
                    stt   = +1;
                }
                else if (so_luong_nhap == int.Parse(TextBox2.Text))
                {
                    khoan = 0;
                    stt   = 0;
                }
                else
                {
                    khoan = int.Parse(TextBox2.Text) - so_luong_nhap;
                    stt   = +1;
                }

                if (stt == -1 && khoan > sl_kho)
                {
                    loi = "Số lượng sửa giảm xuống vượt quá số lượng trong kho!"; int.Parse("a");
                }
                SqlConnection connDB = new SqlConnection(connect.getconnect());
                SqlCommand    cmd    = new SqlCommand("chi_tiet_phieu_nhap_sua", connDB);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id_san_pham", SqlDbType.NVarChar).Value       = id_san_pham;
                cmd.Parameters.Add("@id_phieu_nhap", SqlDbType.NVarChar).Value     = id_phieu_nhap;
                cmd.Parameters.Add("@so_luong_nhap", SqlDbType.NVarChar).Value     = TextBox2.Text;
                cmd.Parameters.Add("@id_kho_hang", SqlDbType.NVarChar).Value       = id_kho;
                cmd.Parameters.Add("@stt", SqlDbType.NVarChar).Value               = stt;
                cmd.Parameters.Add("@khoan", SqlDbType.NVarChar).Value             = khoan;
                cmd.Parameters.Add("@gia_nhap_san_pham", SqlDbType.NVarChar).Value = TextBox3.Text;
                connDB.Open();
                cmd.ExecuteNonQuery();
                connDB.Close();

                Response.Write("<script language='javascript'> alert('Sửa thành công');  window.open('" + Session["PhieuNhap"].ToString() + "','_self', 1);</script>");
            }
            catch (Exception x)
            {
                Response.Write("<script language='javascript'> alert('" + loi + "'); history.go(-1); </script>");
            }
        }
Пример #11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string id_phieu_nhap = "", id_san_pham = "";

            try
            {
                if (Request.QueryString["id_phieu_nhap"] != null && Request.QueryString["id_phieu_nhap"] != "")
                {
                    id_phieu_nhap = (Request.QueryString["id_phieu_nhap"]);
                }
                if (Request.QueryString["id_san_pham"] != null && Request.QueryString["id_san_pham"] != "")
                {
                    id_san_pham = (Request.QueryString["id_san_pham"]);
                }
            }
            catch (Exception a) { }
            try
            {
                WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();

                System.Data.DataTable ds = new System.Data.DataTable();
                System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                int    id_kho_hang = 0;
                int    them        = 0;
                string sql         = "select so_luong " +
                                     "from chi_tiet_kho_hang ctkh " +
                                     "join ( " +
                                     "select id_kho_hang " +
                                     "from phieu_nhap_hang_hoa where id_phieu_nhap=" + id_phieu_nhap + " " +
                                     ") idkh on ctkh.id_kho_hang=idkh.id_kho_hang " +
                                     "where id_san_pham=" + id_san_pham + "";
                ds = new System.Data.DataTable();
                new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                if (ds == null || ds.Rows.Count == 0)
                {
                    them = 1;
                }
                sql = "select id_kho_hang from phieu_nhap_hang_hoa where id_phieu_nhap=" + id_phieu_nhap;
                ds  = new System.Data.DataTable();
                new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                id_kho_hang = int.Parse(ds.Rows[0][0].ToString());
                SqlConnection connDB = new SqlConnection(connect.getconnect());
                SqlCommand    cmd    = new SqlCommand("chi_tiet_phieu_nhap_them", connDB);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id_phieu_nhap", SqlDbType.NVarChar).Value     = id_phieu_nhap;
                cmd.Parameters.Add("@id_san_pham", SqlDbType.NVarChar).Value       = id_san_pham;
                cmd.Parameters.Add("@id_kho_hang", SqlDbType.NVarChar).Value       = id_kho_hang;
                cmd.Parameters.Add("@them", SqlDbType.NVarChar).Value              = them;
                cmd.Parameters.Add("@so_luong_nhap", SqlDbType.NVarChar).Value     = TextBox2.Text;
                cmd.Parameters.Add("@gia_nhap_san_pham", SqlDbType.NVarChar).Value = TextBox3.Text;
                connDB.Open();
                cmd.ExecuteNonQuery();
                connDB.Close();

                Response.Write("<script language='javascript'> alert('Thêm thành công');  window.open('" + Session["PhieuNhap"].ToString() + "','_self', 1);</script>");
            }
            catch (Exception x)
            {
                Response.Write("<script language='javascript'> alert('Thêm bị lỗi!'); history.go(-1); </script>");
            }
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string loi           = "Lỗi không xóa được!";
            int    xoa           = 0;
            int    id_phieu_nhap = 0;
            int    id_san_pham   = 0;

            try
            {
                if (Request.QueryString["id_phieu_nhap"] != null && Request.QueryString["id_phieu_nhap"] != "")
                {
                    id_phieu_nhap = int.Parse(Request.QueryString["id_phieu_nhap"]);
                }
                if (Request.QueryString["id_san_pham"] != null && Request.QueryString["id_san_pham"] != "")
                {
                    id_san_pham = int.Parse(Request.QueryString["id_san_pham"]);
                }
                if (Request.QueryString["xoa"] != null && Request.QueryString["xoa"] != "")
                {
                    xoa = int.Parse(Request.QueryString["xoa"]);
                }
            }
            catch (Exception a) { }

            if (xoa != 0 && id_phieu_nhap != 0 && id_san_pham != 0)
            {
                try
                {
                    WebApplication2.YNNSHOP56131778.CONGFIG.connect connect = new WebApplication2.YNNSHOP56131778.CONGFIG.connect();
                    System.Data.DataTable ds = new System.Data.DataTable();
                    System.Data.SqlClient.SqlConnection ketnoi = new System.Data.SqlClient.SqlConnection(connect.getconnect());
                    string sql = "select id_kho_hang from phieu_nhap_hang_hoa where id_phieu_nhap=" + id_phieu_nhap;
                    ds = new System.Data.DataTable();
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    int id_kho_hang = int.Parse(ds.Rows[0][0].ToString());
                    sql = "select so_luong " +
                          "from chi_tiet_kho_hang " +
                          "where id_kho_hang=" + id_kho_hang + " and id_san_pham=" + id_san_pham;
                    ds = new System.Data.DataTable();
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    int so_luong_trong_kho = int.Parse(ds.Rows[0][0].ToString());

                    sql = "select so_luong_nhap " +
                          "from chi_tiet_phieu_nhap " +
                          "where id_phieu_nhap=" + id_phieu_nhap + " and id_san_pham=" + id_san_pham;
                    ds = new System.Data.DataTable();
                    new System.Data.SqlClient.SqlDataAdapter(new System.Data.SqlClient.SqlCommand(sql, ketnoi)).Fill(ds);
                    int so_luong_phieu_nhap = int.Parse(ds.Rows[0][0].ToString());
                    if (so_luong_phieu_nhap > so_luong_trong_kho)
                    {
                        loi = "không xóa được! Số lượng sản phẩm trong phiếu nhập lớn hơn số lượng sản phẩm trong kho!";
                        int.Parse("a");
                    }
                    SqlConnection connDB = new SqlConnection(connect.getconnect());
                    SqlCommand    cmd    = new SqlCommand("chi_tiet_phieu_nhap_xoa", connDB);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id_san_pham", SqlDbType.NVarChar).Value   = id_san_pham;
                    cmd.Parameters.Add("@id_phieu_nhap", SqlDbType.NVarChar).Value = id_phieu_nhap;
                    cmd.Parameters.Add("@so_luong_nhap", SqlDbType.NVarChar).Value = so_luong_phieu_nhap;
                    cmd.Parameters.Add("@id_kho_hang", SqlDbType.NVarChar).Value   = id_kho_hang;
                    connDB.Open();
                    cmd.ExecuteNonQuery();
                    connDB.Close();
                    Response.Write("<script language='javascript'> alert('Xóa thành công'); window.open('" + Session["PhieuNhap"].ToString() + "','_self', 1);</script>");
                }
                catch (Exception x)
                {
                    Response.Write("<script language='javascript'> alert('" + loi + "');history.go(-1); </script>");
                }
            }
        }