Beispiel #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();
                DateTime NgayKiemKho = DateTime.Parse(txtNgayLapPhieu.Text.ToString());
                string   IDKho       = Session["IDKho"].ToString();
                string   GhiChu      = txtGhiChu.Text == null ? "" : txtGhiChu.Text.ToString();
                data = new dtKiemKho();
                object ID1 = data.ThemPhieu_Temp();
                if (ID1 != null)
                {
                    data.CapNhatPhieuKiemKho(ID1, IDNguoiDung, NgayKiemKho, IDKho, GhiChu);
                    foreach (DataRow dr in db.Rows)
                    {
                        string IDHangHoa   = dr["IDHangHoa"].ToString();
                        string TonKho      = dr["TonKho"].ToString();
                        float  ChenhLech   = float.Parse(dr["ChenhLech"].ToString());
                        string ThucTe      = dr["ThucTe"].ToString();
                        string MaHang      = dr["MaHang"].ToString();
                        string IDDonViTinh = dr["IDDonViTinh"].ToString();
                        string IDKe        = "";
                        data = new dtKiemKho();
                        data.ThemPhieuKiemKho(ID1, IDHangHoa, TonKho, ChenhLech.ToString(), ThucTe, MaHang, IDDonViTinh, IDKe);
                        if (ChenhLech > 0)
                        {
                            object TheKho1 = dtTheKho.ThemTheKho("", "Kiểm kho: " + dtTheKho.LayTenKho_ID(IDKho), "0", "0", (dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, IDKho) + ChenhLech).ToString(), Session["IDNhanVien"].ToString(), IDKho, IDHangHoa, "Nhập", "0", "0", ChenhLech.ToString());
                            if (TheKho1 != null)
                            {
                                dtCapNhatTonKho.CapNhatKho(IDHangHoa, ThucTe, IDKho);
                            }
                        }
                        else if (ChenhLech < 0)
                        {
                            object TheKho2 = dtTheKho.ThemTheKho("", "Kiểm kho: " + dtTheKho.LayTenKho_ID(IDKho), "0", "0", (dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, IDKho) + ChenhLech).ToString(), Session["IDNhanVien"].ToString(), IDKho, IDHangHoa, "Xuất", "0", "0", ChenhLech.ToString());
                            if (TheKho2 != null)
                            {
                                dtCapNhatTonKho.CapNhatKho(IDHangHoa, ThucTe, IDKho);
                            }
                        }
                    }
                    data = new dtKiemKho();
                    data.XoaPhieuKiemKho_Temp_IDPhieuKiemKho(IDPhieuKiemKho);
                    Response.Redirect("DanhSachKiemKho.aspx");
                    //dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Kiểm Kho", Session["IDKho"].ToString(), "Nhập xuất tồn", "Thêm");
                }
                else
                {
                    Response.Write("<script language='JavaScript'> alert('Cập nhật không thành công.'); </script>");
                }
            }
            else
            {
                txtBarcode.Focus();
                Response.Write("<script language='JavaScript'> alert('Danh sách kiểm kho rỗng.'); </script>");
            }
        }
Beispiel #2
0
        protected void btnHuy_Click(object sender, EventArgs e)
        {
            data = new dtKiemKho();
            string IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();

            data.XoaPhieuKiemKho_Temp_IDPhieuKiemKho(IDPhieuKiemKho);
            Response.Redirect("DanhSachKiemKho.aspx");
        }
Beispiel #3
0
 protected void cmbKe_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbKe.Text != "")
     {
         // kiểm kho phải kiểm từng kệ.
         data = new dtKiemKho();
         data.XoaPhieuKiemKho_Temp_IDPhieuKiemKho(IDPhieuKiemKho_Temp.Value.ToString());
         Random ran = new Random();
         IDPhieuKiemKho_Temp.Value = ran.Next(100000, 999999).ToString();
         dtKe      k  = new dtKe();
         DataTable db = k.DanhSachChiTietKe(cmbKe.Value.ToString());
         if (db.Rows.Count > 0)
         {
             string IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();
             foreach (DataRow dr in db.Rows)
             {
                 string    IDHangHoa  = dr["IDHangHoa"].ToString();
                 string    MaHang     = dr["MaHang"].ToString();
                 string    IDonViTinh = dr["IDonViTinh"].ToString();
                 int       TonKho     = dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, Session["IDKho"].ToString());
                 int       ChechLech  = -TonKho;
                 DataTable dt         = data.KTChiTietPhieuKiemKho_Temp(IDHangHoa, IDPhieuKiemKho, cmbKe.Value.ToString());
                 if (dt.Rows.Count == 0)
                 {
                     data = new dtKiemKho();
                     data.ThemPhieuKiemKho_Temp(IDPhieuKiemKho, IDHangHoa, TonKho, ChechLech, MaHang, IDonViTinh, cmbKe.Value.ToString());
                 }
             }
             LoadGrid(IDPhieuKiemKho);
         }
         else
         {
             Response.Write("<script language='JavaScript'> alert('Kệ chưa có hàng hóa.'); </script>");
         }
     }
 }