Esempio n. 1
0
 protected void btnThem_Click(object sender, EventArgs e)
 {
     if (txtTenHangHoa.Text != "" && txtGiaBan.Text != "" && cmbDonViTinh.Text != "" && cmbNhomHang.Text != "")
     {
         string IDHangHoa   = IDHangHoa_Temp.Value.ToString();
         string MaHangHoa   = txtMaHang.Text.ToString();
         string TenHangHoa  = txtTenHangHoa.Text.ToString();
         string GiaBan      = txtGiaBan.Text.ToString();
         string IDDonViTinh = cmbDonViTinh.Value.ToString();
         string IDNhomHang  = cmbNhomHang.Value.ToString();
         string GhiChu      = txtGhiChu.Text == null ? "" : txtGhiChu.Text.ToString();
         data = new dtThemHangHoa();
         object ID = data.ThemHangHoa();
         if (ID != null)
         {
             data.CapNhatHangHoa(ID, MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu);
             DataTable dt = data.NguyenLieu_Temp(IDHangHoa);
             if (dt.Rows.Count > 0)
             {
                 foreach (DataRow dr in dt.Rows)
                 {
                     string IDNguyenLieu = dr["IDNguyenLieu"].ToString();
                     string TrongLuong   = dr["TrongLuong"].ToString();
                     string MaNguyenLieu = dr["MaNguyenLieu"].ToString();
                     string NhaCungCap   = dr["NhaCungCap"].ToString();
                     string IDDonViTinh1 = dr["IDDonViTinh"].ToString();
                     data = new dtThemHangHoa();
                     data.ThemChiTietNguyenLieu(ID, IDNguyenLieu, TrongLuong, MaNguyenLieu, NhaCungCap, IDDonViTinh1);
                 }
             }
             data = new dtThemHangHoa();
             data.XoaChiTiet_Temp_ID(IDHangHoa);
             dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Thêm hàng hóa", "Thêm hàng hóa có nguyên liệu");
             Response.Redirect("QuanLyHangHoa.aspx");
         }
     }
     else
     {
         Response.Write("<script language='JavaScript'> alert('Trường  (*) không được bỏ trống .'); </script>");
     }
 }
Esempio n. 2
0
 private void LoadGrid(string p)
 {
     data = new dtThemHangHoa();
     gridNguyenLieu.DataSource = data.NguyenLieu_Temp(p);
     gridNguyenLieu.DataBind();
 }