Пример #1
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            string    IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();
            DataTable db             = data.DanhSachKiemKhoTemp_IDPhieuKiemKho(IDPhieuKiemKho);

            if (db.Rows.Count > 0)
            {
                string   IDNguoiDung = Session["IDNhanVien"].ToString();
                string   IDChiNhanh  = Session["IDChiNhanh"].ToString();
                DateTime NgayKiemKho = DateTime.Parse(txtNgayLapPhieu.Text.ToString());
                string   GhiChu      = txtGhiChu.Text == null ? "" : txtGhiChu.Text.ToString();
                data = new dtKiemKho();
                data.CapNhatPhieuKiemKho(IDPhieuKiemKho, IDNguoiDung, NgayKiemKho, GhiChu, IDChiNhanh);
                foreach (DataRow dr in db.Rows)
                {
                    string IDNguyenLieu = dr["IDNguyenLieu"].ToString();
                    string TonKho       = dr["TonKho"].ToString();
                    string ChenhLech    = dr["ChenhLech"].ToString();
                    string ThucTe       = dr["ThucTe"].ToString();
                    string MaNguyenLieu = dr["MaNguyenLieu"].ToString();
                    string IDDonViTinh  = dr["IDDonViTinh"].ToString();
                    data = new dtKiemKho();
                    data.ThemPhieuKiemKho(IDPhieuKiemKho, IDNguyenLieu, TonKho, ChenhLech, ThucTe, MaNguyenLieu, IDDonViTinh);
                }
                data = new dtKiemKho();
                data.XoaPhieuKiemKho_Temp_IDPhieuKiemKho2(IDPhieuKiemKho);
                Response.Redirect("DanhSachKiemKho.aspx");
            }
            else
            {
                cmbHangHoa.Focus();
                Response.Write("<script language='JavaScript'> alert('Danh sách kiểm kho rỗng.'); </script>");
            }
        }