Пример #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();
                        double ChenhLech   = double.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>");
            }
        }
Пример #2
0
 protected void btnThemTemp_Click(object sender, EventArgs e)
 {
     if (txtBarcode.Text != "")
     {
         string      IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();
         dtBanHangLe dt             = new dtBanHangLe();
         DataTable   tbThongTin     = dt.LayThongTinHangHoa_ThemDonHang(txtBarcode.Value.ToString());
         if (tbThongTin.Rows.Count > 0)
         {
             string    IDHangHoa   = tbThongTin.Rows[0]["ID"].ToString();
             string    MaHangHoa   = tbThongTin.Rows[0]["MaHang"].ToString();
             string    IDDonViTinh = dtHangHoa.LayIDDonViTinh(IDHangHoa);
             float     TonKho      = dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, Session["IDKho"].ToString());
             float     ChechLech   = -TonKho;
             DataTable dt1         = data.KTChiTietPhieuKiemKho_Temp(IDHangHoa, IDPhieuKiemKho);
             if (dt1.Rows.Count == 0)
             {
                 data = new dtKiemKho();
                 data.ThemPhieuKiemKho_Temp(IDPhieuKiemKho, IDHangHoa, TonKho, ChechLech, MaHangHoa, IDDonViTinh);
             }
             LoadGrid(IDPhieuKiemKho);
         }
         txtBarcode.Text  = "";
         txtBarcode.Value = "";
         txtBarcode.Focus();
     }
 }
Пример #3
0
        private void LoadGrid()
        {
            data = new dtKiemKho();
            gridDanhSachKiemKho.DataSource = data.DanhSachKiemKho();
            gridDanhSachKiemKho.DataBind();

            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Danh sách kiểm kho", "Truy cập");
        }
Пример #4
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");
        }
Пример #5
0
        protected void gridDanhSachHangHoa_Temp_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID             = e.Keys[0].ToString();
            string IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();

            data = new dtKiemKho();
            data.XoaPhieuKiemKho_Temp_ID(ID);
            e.Cancel = true;
            gridDanhSachHangHoa_Temp.CancelEdit();
            LoadGrid(IDPhieuKiemKho);
        }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         data = new dtKiemKho();
         object IDPhieuKiemKho = data.ThemPhieu_Temp();
         IDPhieuKiemKho_Temp.Value = IDPhieuKiemKho.ToString();
         txtChiNhanh.Text          = Session["IDChiNhanh"].ToString();
         txtNguoiLapPhieu.Text     = Session["TenDangNhap"] == null ? "" : Session["TenDangNhap"].ToString();
     }
     LoadGrid(IDPhieuKiemKho_Temp.Value.ToString());
 }
        protected void btnDuyet_Click(object sender, EventArgs e)
        {
            data = new dtKiemKho();
            string    IDPhieuKiemKho = Request.QueryString["IDPhieuKiemKho"];
            DataTable dt             = data.DanhSachChiTietPhieuKiemKho_IDPhieuKiemKho(Int32.Parse(IDPhieuKiemKho));

            if (dt.Rows.Count > 0)
            {
                string IDKho = dtKiemKho.LayIDKho_PhieuKiem(IDPhieuKiemKho);
                if (IDKho != "")
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string ThucTe    = dr["ThucTe"].ToString();
                        string IDHangHoa = dr["IDHangHoa"].ToString();
                        // lấy chênh lệch lưu lại thẻ kho
                        int ChenhLech = Int32.Parse(dr["ChenhLech"].ToString());
                        if (ChenhLech > 0)
                        {
                            object TheKho1 = dtTheKho.ThemTheKho("", "Kiểm kho: " + dtTheKho.LayTenKho_ID(IDKho), "0", "0", (Int32.Parse(dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, IDKho).ToString()) + 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", (Int32.Parse(dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa, IDKho).ToString()) + 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.CapNhatTrangThai(IDPhieuKiemKho);
                    btnDuyet.Enabled = false;
                    gridChiTietPhieuKiemKho.Columns["chucnang"].Visible = false;

                    //  dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Chi tiết phiếu kiểm kho", Session["IDKho"].ToString(), "Nhập xuất tồn", "Duyệt");
                }
            }
            else
            {
                Response.Write("<script language='JavaScript'> alert('Danh sách kiểm kho rỗng'); </script>");
            }
        }
Пример #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["KTDangNhap"] != "GPM@2017")
     {
         Response.Redirect("DangNhap.aspx");
     }
     else
     {
         if (!IsPostBack)
         {
             data = new dtKiemKho();
             // object IDPhieuKiemKho = data.ThemPhieu_Temp();
             IDPhieuKiemKho_Temp.Value = Session["IDNhanVien"].ToString();
             txtChiNhanh.Text          = Session["IDChiNhanh"].ToString();
             txtNguoiLapPhieu.Text     = Session["TenDangNhap"] == null ? "" : Session["TenDangNhap"].ToString();
         }
         LoadGrid(IDPhieuKiemKho_Temp.Value.ToString());
     }
 }
Пример #9
0
        protected void gridDanhSachHangHoa_Temp_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string IDPhieuKiemKho = IDPhieuKiemKho_Temp.Value.ToString();
            string ID             = e.Keys[0].ToString();
            float  ThucTe         = float.Parse(e.NewValues["ThucTe"].ToString());

            if (ThucTe >= 0)
            {
                float TonKho = float.Parse(e.NewValues["TonKho"].ToString());
                data = new dtKiemKho();
                data.CapNhatPhieuKiemKho_Temp(ID, ThucTe.ToString(), (ThucTe - TonKho).ToString());
                e.Cancel = true;
                gridDanhSachHangHoa_Temp.CancelEdit();
                LoadGrid(IDPhieuKiemKho);
            }
            else
            {
                throw new Exception("Lỗi: Số lượng thực tế phải  >= 0");
            }
        }
        protected void gridChiTietPhieuKiemKho_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string IDPhieuKiemKho = Request.QueryString["IDPhieuKiemKho"];
            string ID             = e.Keys[0].ToString();
            float  ThucTe         = float.Parse(e.NewValues["ThucTe"].ToString());
            float  TonKho         = float.Parse(e.NewValues["TonKho"].ToString());

            if (ThucTe >= 0)
            {
                data = new dtKiemKho();
                data.CapNhatPhieuKiemKho_Chinh(ID, ThucTe.ToString(), (ThucTe - TonKho).ToString());
                e.Cancel = true;
                gridChiTietPhieuKiemKho.CancelEdit();
                LoadGrid(Int32.Parse(IDPhieuKiemKho.ToString()));
            }
            else
            {
                throw new Exception("Lỗi: Số lượng thực tế phải  >= 0");
            }
        }
Пример #11
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();
                object ID = data.ThemPhieu_Temp();
                if (ID != null)
                {
                    data.CapNhatPhieuKiemKho(ID, 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(ID, 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>");
            }

            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Kiểm kho", "Tạo phiếu kiểm kho");
        }
        protected void gridChiTietPhieuKiemKho_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string IDPhieuKiemKho = Request.QueryString["IDPhieuKiemKho"];
            string ID             = e.Keys[0].ToString();
            int    ThucTe         = Int32.Parse(e.NewValues["ThucTe"].ToString());
            int    TonKho         = Int32.Parse(e.NewValues["TonKho"].ToString());

            if (ThucTe >= 0)
            {
                data = new dtKiemKho();
                data.CapNhatPhieuKiemKho_Chinh(ID, ThucTe, ThucTe - TonKho);
                e.Cancel = true;
                gridChiTietPhieuKiemKho.CancelEdit();
                LoadGrid(Int32.Parse(IDPhieuKiemKho.ToString()));

                dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Chi tiết phiếu kiểm kho", Session["IDKho"].ToString(), "Nhập xuất tồn", "Cập nhật");
            }
            else
            {
                throw new Exception("Lỗi: Số lượng thực tế phải  >= 0");
            }
        }
Пример #13
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>");
         }
     }
 }
        protected void gridChiTietPhieuKiemKho_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID = e.Keys[0].ToString();

            data = new dtKiemKho();
        }
 private void LoadGrid()
 {
     data = new dtKiemKho();
     gridDanhSachKiemKho.DataSource = data.DanhSachKiemKho();
     gridDanhSachKiemKho.DataBind();
 }
 private void LoadGrid()
 {
     data = new dtKiemKho();
     gridDanhSachKiemKho.DataSource = data.DanhSachKiemKho(Session["IDKho"].ToString());
     gridDanhSachKiemKho.DataBind();
 }
 private void LoadGrid(int IDPhieuKiemKho)
 {
     data = new dtKiemKho();
     gridChiTietPhieuKiemKho.DataSource = data.DanhSachChiTietPhieuKiemKho_IDPhieuKiemKho(IDPhieuKiemKho);
     gridChiTietPhieuKiemKho.DataBind();
 }
Пример #18
0
 public void LoadGrid(string IDPhieuKiemKho)
 {
     data = new dtKiemKho();
     gridDanhSachHangHoa_Temp.DataSource = data.DanhSachKiemKhoTemp_IDPhieuKiemKho(IDPhieuKiemKho);
     gridDanhSachHangHoa_Temp.DataBind();
 }