コード例 #1
0
        protected void gridHangHoa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dtHangHoa();
            string MaHangHoa   = dtHangHoa.Dem_Max();
            string TenHangHoa  = e.NewValues["TenHangHoa"].ToString();
            string GiaBan      = e.NewValues["GiaBan"].ToString();
            string IDDonViTinh = e.NewValues["IDDonViTinh"].ToString();
            string IDNhomHang  = e.NewValues["IDNhomHang"].ToString();
            string GhiChu      = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString();
            string IDChiNhanh  = Session["IDChiNhanh"].ToString();
            object ID          = data.ThemHangHoa(MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu, IDChiNhanh);

            if (ID != null)
            {
                //thêm vào all bảng giá
                dtBangGia bg  = new dtBangGia();
                DataTable dbt = bg.DanhSach(IDChiNhanh);
                foreach (DataRow dr in dbt.Rows)
                {
                    string IDBangGia = dr["ID"].ToString();
                    bg.ThemIDHangHoaVaoChiTietGia(ID.ToString(), IDBangGia, GiaBan, IDChiNhanh);
                }
            }
            e.Cancel = true;
            gridHangHoa.CancelEdit();
            LoadGrid();

            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Quản lý hàng hóa", "Thêm hàng hóa: " + TenHangHoa);
        }
コード例 #2
0
        protected void gridChiTietPhieuKiemKho_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string    ID     = e.Keys[0].ToString();
            string    GiaMoi = e.NewValues["GiaMoi"] == null ? "0" : e.NewValues["GiaMoi"].ToString();
            dtHangHoa dt     = new dtHangHoa();

            data = new dtBangGia();

            DataTable da = dt.LayDanhSachHangHoa_MaHang(e.NewValues["MaHangHoa"].ToString());

            if (da.Rows.Count != 0)
            {
                DataRow dr    = da.Rows[0];
                float   GiaCu = dt.LaySoTienCu_ChiTietGia(ID);
                if (float.Parse(GiaMoi) != GiaCu)
                {
                    dtThayDoiGia.ThemLichSu(Session["IDNhanVien"].ToString(), dr["MaHangHoa"].ToString(), dr["TenHangHoa"].ToString(), dr["IDDonViTinh"].ToString(), GiaCu + "", GiaMoi, Session["IDChiNhanh"].ToString());
                }
            }

            data.CapNhatGiaChiTiet(ID, GiaMoi);
            e.Cancel = true;
            gridChiTietPhieuKiemKho.CancelEdit();
            string IDBangGia = Request.QueryString["IDBangGia"];

            if (IDBangGia != null)
            {
                LoadGrid(IDBangGia);
            }
        }
コード例 #3
0
        protected void gridHangHoa_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            data = new dtHangHoa();
            string ID          = e.Keys[0].ToString();
            string MaHangHoa   = e.NewValues["MaHangHoa"].ToString();
            string TenHangHoa  = e.NewValues["TenHangHoa"].ToString();
            string GiaBan      = e.NewValues["GiaBan"].ToString();
            string IDDonViTinh = e.NewValues["IDDonViTinh"].ToString();
            string IDNhomHang  = e.NewValues["IDNhomHang"].ToString();
            string GhiChu      = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString();
            float  GiaCu       = data.LaySoTienCu(ID);

            if (GiaCu != float.Parse(GiaBan))
            {
                dtThayDoiGia.ThemLichSu(Session["IDNhanVien"].ToString(), MaHangHoa, TenHangHoa, IDDonViTinh, GiaCu + "", GiaBan, Session["IDChiNhanh"].ToString());
                dtBangGia bg = new dtBangGia();
                bg.CapNhatGiaCuTrongChiTietBangGia(ID, GiaBan);
            }
            data.SuaHangHoa(ID, MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu);
            e.Cancel = true;
            gridHangHoa.CancelEdit();
            LoadGrid();

            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Quản lý hàng hóa", "Cập nhật hàng hóa: " + ID);
        }
コード例 #4
0
        protected void gridBarCode_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dtHangHoa();
            ASPxGridView gridBarCode  = sender as ASPxGridView;
            object       IDHangHoa    = gridBarCode.GetMasterRowKeyValue();
            string       IDNguyenLieu = e.NewValues["IDNguyenLieu"].ToString();
            string       TrongLuong   = e.NewValues["TrongLuong"].ToString();
            string       MaNguyenLieu = dtThemHangHoa.LayMaNguyenLieu(IDNguyenLieu);
            string       NhaCungCap   = dtThemHangHoa.LayNhaCungCap(IDNguyenLieu);
            string       IDDonViTinh  = dtThemHangHoa.LayIDDonViTinh(IDNguyenLieu);
            DataTable    dt           = data.KT_NguyenLieu(IDHangHoa, IDNguyenLieu);

            if (dt.Rows.Count == 0)
            {
                data.ThemNguyenLieu(IDHangHoa, IDNguyenLieu, TrongLuong, MaNguyenLieu, NhaCungCap, IDDonViTinh);
            }
            else
            {
                throw new Exception("Lỗi: Nguyên liệu chế biến đã tồn tại?");
            }
            e.Cancel = true;
            gridBarCode.CancelEdit();
            gridBarCode.DataSource = data.GetListBarCode(IDHangHoa);
            gridBarCode.DataBind();
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string NgayBD     = Request.QueryString["ngayBD"];
            string NgayKT     = Request.QueryString["NgayKT"];
            string IDHangHoa  = Request.QueryString["IDHangHoa"];
            string strHangHoa = "Tất cả";

            if (Int32.Parse(IDHangHoa) != -1)
            {
                dtHangHoa dt = new dtHangHoa();
                strHangHoa = dt.LayTenHangHoa(IDHangHoa);
            }

            string strNgay         = DateTime.Parse(NgayBD).ToString("dd-MM-yyyy") + " - " + DateTime.Parse(NgayKT).ToString("dd-MM-yyyy");
            rpBKXuatNhapChiTiet rp = new rpBKXuatNhapChiTiet();

            rp.Parameters["IDHangHoa"].Value    = IDHangHoa;
            rp.Parameters["IDHangHoa"].Visible  = false;
            rp.Parameters["strHangHoa"].Value   = strHangHoa;
            rp.Parameters["strHangHoa"].Visible = false;
            rp.Parameters["strNgay"].Value      = strNgay;
            rp.Parameters["strNgay"].Visible    = false;
            rp.Parameters["NgayBD"].Value       = NgayBD;
            rp.Parameters["NgayBD"].Visible     = false;
            rp.Parameters["NgayKT"].Value       = NgayKT;
            rp.Parameters["NgayKT"].Visible     = false;
            viewerReport.Report = rp;
        }
コード例 #6
0
        private void BatchUpdate()
        {
            txtKhachThanhToan.Text = "0";
            int    MaHoaDon = tabControlSoHoaDon.ActiveTabIndex;
            string IDKho    = Session["IDKho"].ToString();

            for (int i = 0; i < gridChiTietHoaDon.VisibleRowCount; i++)
            {
                object       SoLuong            = gridChiTietHoaDon.GetRowValues(i, "SoLuong");
                object       GiaKyThuat         = gridChiTietHoaDon.GetRowValues(i, "GiaKyThuat");
                ASPxSpinEdit spineditSoLuong    = gridChiTietHoaDon.FindRowCellTemplateControl(i, (GridViewDataColumn)gridChiTietHoaDon.Columns["SoLuong"], "txtSoLuongChange") as ASPxSpinEdit;
                ASPxSpinEdit spineditGiaKyThuat = gridChiTietHoaDon.FindRowCellTemplateControl(i, (GridViewDataColumn)gridChiTietHoaDon.Columns["GiaKyThuat"], "txtGiaKyThuatChange") as ASPxSpinEdit;
                object       SoLuongMoi         = spineditSoLuong.Value;
                object       GiaMoi             = spineditGiaKyThuat.Value;
                if (SoLuong != SoLuongMoi || GiaKyThuat != GiaMoi)
                {
                    if (dtSetting.KT_BanHang(IDKho) == 1)
                    {
                        //bán âm
                        int    STT          = Convert.ToInt32(gridChiTietHoaDon.GetRowValues(i, "STT"));
                        var    exitHang     = DanhSachHoaDon[MaHoaDon].ListChiTietHoaDon.FirstOrDefault(item => item.STT == STT);
                        int    SoLuongOld   = exitHang.SoLuong;
                        double ThanhTienOld = exitHang.ThanhTien;
                        exitHang.SoLuong    = Convert.ToInt32(SoLuongMoi);
                        exitHang.GiaKyThuat = double.Parse(spineditGiaKyThuat.Value.ToString());
                        exitHang.ThanhTien  = Convert.ToInt32(SoLuongMoi) * exitHang.GiaKyThuat;
                        DanhSachHoaDon[MaHoaDon].TongTien   += exitHang.ThanhTien - ThanhTienOld;
                        DanhSachHoaDon[MaHoaDon].KhachCanTra = DanhSachHoaDon[MaHoaDon].TongTien - DanhSachHoaDon[MaHoaDon].GiamGia;
                    }
                    else
                    {
                        //không bán âm
                        int       MaHang          = Convert.ToInt32(gridChiTietHoaDon.GetRowValues(i, "MaHang"));
                        dtHangHoa dtt             = new dtHangHoa();
                        int       IDHangHoa       = Int32.Parse(dtHangHoa.LayIDHangHoa_MaHang(MaHang + ""));
                        int       SLTonKhoHienTai = dtCapNhatTonKho.SoLuong_TonKho(IDHangHoa.ToString(), IDKho);
                        if (SLTonKhoHienTai >= Int32.Parse(SoLuongMoi + ""))
                        {
                            int    STT          = Convert.ToInt32(gridChiTietHoaDon.GetRowValues(i, "STT"));
                            var    exitHang     = DanhSachHoaDon[MaHoaDon].ListChiTietHoaDon.FirstOrDefault(item => item.STT == STT);
                            int    SoLuongOld   = exitHang.SoLuong;
                            double ThanhTienOld = exitHang.ThanhTien;
                            exitHang.SoLuong    = Convert.ToInt32(SoLuongMoi);
                            exitHang.GiaKyThuat = double.Parse(spineditGiaKyThuat.Value.ToString());
                            exitHang.ThanhTien  = Convert.ToInt32(SoLuongMoi) * exitHang.DonGia;
                            DanhSachHoaDon[MaHoaDon].TongTien   += exitHang.ThanhTien - ThanhTienOld;
                            DanhSachHoaDon[MaHoaDon].KhachCanTra = DanhSachHoaDon[MaHoaDon].TongTien - DanhSachHoaDon[MaHoaDon].GiamGia;
                        }
                        else
                        {
                            txtSoLuong.Text = SLTonKhoHienTai + "";
                            HienThiThongBao("Số lượng tồn kho không đủ bán? Vui lòng liên hệ kho tổng.");
                        }
                    }
                }
            }
        }
コード例 #7
0
        protected void gridBarCode_Init(object sender, EventArgs e)
        {
            data = new dtHangHoa();
            ASPxGridView gridBarCode = sender as ASPxGridView;
            object       IDHangHoa   = gridBarCode.GetMasterRowKeyValue();

            gridBarCode.DataSource = data.GetListBarCode(IDHangHoa);
            gridBarCode.DataBind();
        }
コード例 #8
0
        protected void gridHangHoa_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID = e.Keys[0].ToString();

            data = new dtHangHoa();
            data.XoaHangHoa(ID);
            e.Cancel = true;
            gridHangHoa.CancelEdit();
            LoadGrid();
        }
コード例 #9
0
        protected void gridHangHoa_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID = e.Keys[0].ToString();

            data = new dtHangHoa();
            data.XoaHangHoa(ID);
            e.Cancel = true;
            gridHangHoa.CancelEdit();
            LoadGrid();
            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Quản lý hàng hóa", "Xóa hàng hóa: " + ID);
        }
コード例 #10
0
        protected void gridBarCode_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            data = new dtHangHoa();
            int ID = Int32.Parse(e.Keys["ID"].ToString());

            data.XoaNguyenLieu(ID);
            e.Cancel = true;
            ASPxGridView gridBarCode = sender as ASPxGridView;
            object       IDHangHoa   = gridBarCode.GetMasterRowKeyValue();

            gridBarCode.DataSource = data.GetListBarCode(IDHangHoa);
            gridBarCode.DataBind();
        }
コード例 #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         dtHangHoa dt = new dtHangHoa();
         DataTable da = dt.DanhSachNguyenLieu_BK();
         da.Rows.Add(-1, "Tất cả");
         cmbHangHoa.DataSource = da;
         cmbHangHoa.TextField  = "TenNguyenLieu";
         cmbHangHoa.ValueField = "ID";
         cmbHangHoa.DataBind();
         cmbHangHoa.SelectedIndex = da.Rows.Count;
     }
 }
コード例 #12
0
        protected void gridHangHoa_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dtHangHoa();
            string MaHangHoa   = e.NewValues["MaHangHoa"].ToString();
            string TenHangHoa  = e.NewValues["TenHangHoa"].ToString();
            string GiaBan      = e.NewValues["GiaBan"].ToString();
            string IDDonViTinh = e.NewValues["IDDonViTinh"].ToString();
            string IDNhomHang  = e.NewValues["IDNhomHang"].ToString();
            string GhiChu      = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString();

            data.ThemHangHoa(MaHangHoa, TenHangHoa, GiaBan, IDDonViTinh, IDNhomHang, GhiChu);
            e.Cancel = true;
            gridHangHoa.CancelEdit();
            LoadGrid();
        }
コード例 #13
0
        protected void gridBangGia_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            string TenBangGia = e.NewValues["TenBangGia"].ToString();

            data = new dtBangGia();
            object ID = data.ThemMoi(TenBangGia);

            if (ID != null)
            {
                dtHangHoa hh = new dtHangHoa();
                DataTable db = hh.LayDanhSachHangHoa();
                foreach (DataRow dr in db.Rows)
                {
                    string IDHangHoa = dr["ID"].ToString();
                    string GiaBan    = dr["GiaBan"].ToString();
                    data = new dtBangGia();
                    data.ThemIDHangHoaVaoChiTietGia(IDHangHoa, ID, GiaBan);
                }
            }
            e.Cancel = true;
            gridBangGia.CancelEdit();
            LoadGrid();
        }
コード例 #14
0
        protected void gridChiTietPhieuKiemKho_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            string    ID       = e.Keys[0].ToString();
            string    GiaBanLe = e.NewValues["GiaBanLe"] == null ? "0" : e.NewValues["GiaBanLe"].ToString();
            string    GiaBanSi = e.NewValues["GiaBanSi"] == null ? "0" : e.NewValues["GiaBanSi"].ToString();
            dtHangHoa dt       = new dtHangHoa();

            data = new dtBangGia();

            DataTable da = dt.LayDanhSachHangHoa_MaHang(e.NewValues["MaHang"].ToString());

            if (da.Rows.Count != 0)
            {
                DataRow dr         = da.Rows[0];
                double  GiaBanSiCu = dt.LaySoTienCu_ChiTietGia_GiaBanSi(ID);
                double  GiaBanLeCu = dt.LaySoTienCu_ChiTietGia_GiaBanLe(ID);
                if (double.Parse(GiaBanLe) != GiaBanLeCu)
                {
                    dtThayDoiGia.ThemLichSu(dr["MaHang"].ToString(), dr["TenHangHoa"].ToString(), dr["IDDonViTinhSi"].ToString(), GiaBanLeCu.ToString(), GiaBanLe, Session["IDNhanVien"].ToString(), "Thay đổi giá bán lẻ trong bảng giá");
                }
                if (double.Parse(GiaBanSi) != GiaBanSiCu)
                {
                    dtThayDoiGia.ThemLichSu(dr["MaHang"].ToString(), dr["TenHangHoa"].ToString(), dr["IDDonViTinhSi"].ToString(), GiaBanSiCu.ToString(), GiaBanSi, Session["IDNhanVien"].ToString(), "Thay đổi giá bán sỉ trong bảng giá");
                }
            }

            data.CapNhatGiaChiTiet(ID, GiaBanLe, GiaBanSi);
            e.Cancel = true;
            gridChiTietPhieuKiemKho.CancelEdit();
            string IDBangGia = Request.QueryString["IDBangGia"];

            if (IDBangGia != null)
            {
                LoadGrid(IDBangGia);
            }
        }
コード例 #15
0
        protected void gridChiNhanh_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            string   MaChiNhanh  = dtChiNhanh.Dem_Max();
            string   TenChiNhanh = e.NewValues["TenChiNhanh"].ToString();
            string   DienThoai   = e.NewValues["DienThoai"] == null ? "" : e.NewValues["DienThoai"].ToString();
            string   Email       = e.NewValues["Email"] == null ? "" : e.NewValues["Email"].ToString();
            string   DiaChi      = e.NewValues["DiaChi"] == null ? "" : e.NewValues["DiaChi"].ToString();
            DateTime NgayMo      = DateTime.Parse(e.NewValues["NgayMo"].ToString());
            string   DuLieuMau   = e.NewValues["DuLieuMau"] == null ? "0" : "1";
            string   Key         = RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5) + "-" + RandomString(5);

            data = new dtChiNhanh();
            object ID = data.ThemChiNhanh(MaChiNhanh, TenChiNhanh, DienThoai, DiaChi, NgayMo, DuLieuMau, Key, Email);

            if (ID != null)
            {
                // tạo key kích hoạt
                data = new dtChiNhanh();
                data.ThemKeyKichHoat(Key, ID.ToString());

                // Tạo bảng giá
                dtBangGia dtBangGia = new dtBangGia();
                object    IDBangGia = dtBangGia.ThemMoi("Bảng Giá Thường", ID.ToString());

                // tạo khu vực
                dtKhuVuc dtKhuVuc = new dtKhuVuc();
                object   IDKhuVuc = dtKhuVuc.Them("", "Khu A", "0", ID.ToString(), TenChiNhanh, "A", IDBangGia.ToString());

                //tạo tài khoản
                dtQuanTriNguoiDung dtNguoiDung = new dtQuanTriNguoiDung();
                if (dtQuanTriNguoiDung.KiemTraNguoiDung(DienThoai.Trim()) != -1)
                {
                    throw new Exception("Lỗi: Tên đăng nhập đã tồn tại");
                }
                else
                {
                    dtNguoiDung.ThemNguoiDung(dtQuanTriNguoiDung.Dem_Max(), "Quản trị", DienThoai, 1, DienThoai, dtSetting.GetSHA1HashData(DienThoai), Email, ID.ToString());
                    dtNguoiDung.ThemNguoiDung(dtQuanTriNguoiDung.Dem_Max(), "Thu ngân", "BH." + DienThoai, 2, DienThoai, dtSetting.GetSHA1HashData(DienThoai), Email, ID.ToString());
                }


                if (DuLieuMau == "1")
                {
                    //tạo dữ liệu mẫu, lấy Chi Nhánh 1 ra làm

                    //thêm đVT
                    dtDonViTinh dtDVT = new dtDonViTinh();
                    DataTable   tbdvt = dtDVT.LayDanhSachDonViTinh("1");
                    foreach (DataRow dr in tbdvt.Rows)
                    {
                        dtDVT.ThemDonViTinh(dr["TenDonViTinh"].ToString(), ID.ToString());
                    }

                    //Thêm nhóm hàng
                    dtNhomHangHoa dtNhomHang = new dtNhomHangHoa();
                    DataTable     tbNhomHang = dtNhomHang.DanhSach("1");
                    foreach (DataRow dr1 in tbNhomHang.Rows)
                    {
                        object IDNhomHangMoi = dtNhomHang.Them(dtNhomHangHoa.Dem_Max(), dr1["TenNhom"].ToString(), "", ID.ToString());
                        //Thêm hàng hóa
                        dtHangHoa dtHH = new dtHangHoa();
                        DataTable tbHH = dtHH.DanhSachHangHoa_IDnhomHang(dr1["ID"].ToString(), "1");
                        foreach (DataRow dr in tbHH.Rows)
                        {
                            string IDDVTCU = dr["IDDonViTinh"].ToString();

                            object IDHH = dtHH.ThemHangHoa(dtHangHoa.Dem_Max(), dr["TenHangHoa"].ToString(), dr["GiaBan"].ToString(), dtDonViTinh.LayIDDVT_Moi(IDDVTCU, ID.ToString()), IDNhomHangMoi.ToString(), dr["GhiChu"].ToString(), ID.ToString());
                            if (IDHH != null)
                            {
                                //thêm vào bảng giá
                                dtBangGia bg = new dtBangGia();
                                bg.ThemIDHangHoaVaoChiTietGia(IDHH.ToString(), IDBangGia, dr["GiaBan"].ToString(), ID.ToString());
                            }
                        }
                    }

                    //thêm  30 bàn mẫu
                    for (int i = 1; i <= 30; i++)
                    {
                        dtBan dtB = new dtBan();
                        dtB.Them("", "A - " + i, IDKhuVuc.ToString(), ID.ToString());
                    }
                }
            }
            e.Cancel = true;
            gridChiNhanh.CancelEdit();
            LoadGrid();

            dtLichSuTruyCap.ThemLichSu(Session["IDChiNhanh"].ToString(), Session["IDNhom"].ToString(), Session["IDNhanVien"].ToString(), "Chi nhánh", "Thêm chi nhánh: " + TenChiNhanh);
        }
コード例 #16
0
 private void LoadGrid()
 {
     data = new dtHangHoa();
     gridHangHoa.DataSource = data.LayDanhSachHangHoa();
     gridHangHoa.DataBind();
 }
コード例 #17
0
 private void LoadGrid()
 {
     data = new dtHangHoa();
     gridHangHoa.DataSource = data.LayDanhSachHangHoa(Session["IDChiNhanh"].ToString());
     gridHangHoa.DataBind();
 }