Beispiel #1
0
        private void Init()
        {
            List <object> list = new List <object>
            {
                new { ID = 0, Name = "Hàng hóa" },
                new { ID = 1, Name = "Dịch vụ" }
            };

            cbLoaiHH.Properties.DataSource    = list;
            cbLoaiHH.Properties.DisplayMember = "Name";
            cbLoaiHH.Properties.ValueMember   = "ID";
            LookUpColumnInfo col_t = new LookUpColumnInfo("Name", "");

            cbLoaiHH.Properties.Columns.Add(col_t);
            cbLoaiHH.EditValue = 0;

            leKhoMacDinh.Properties.DataSource    = BUS_KhoXuat.LayKhoDonGian();
            leKhoMacDinh.Properties.DisplayMember = "STOCK_Name";
            leKhoMacDinh.Properties.ValueMember   = "STOCK_ID";
            LookUpColumnInfo col  = new LookUpColumnInfo("STOCK_ID", "Mã");
            LookUpColumnInfo col1 = new LookUpColumnInfo("STOCK_Name", "Tên");

            leKhoMacDinh.Properties.Columns.Add(col1);
            leKhoMacDinh.Properties.Columns.Add(col);
            leKhoMacDinh.EditValue = ((DataTable)leKhoMacDinh.Properties.DataSource).Rows[0]["STOCK_ID"];
            leKhoMacDinh.Properties.Buttons[1].Click += btnThemKho_ThemHangHoa_Click;

            lePhanLoai.Properties.TextEditStyle = TextEditStyles.Standard;
            lePhanLoai.Properties.DataSource    = BUS_HangHoa.LayNhomHang();
            lePhanLoai.Properties.DisplayMember = "ProductGroup_Name";
            lePhanLoai.Properties.ValueMember   = "ProductGroup_ID";
            col  = new LookUpColumnInfo("ProductGroup_ID", "Mã");
            col1 = new LookUpColumnInfo("ProductGroup_Name", "Tên");
            lePhanLoai.Properties.Columns.Add(col1);
            lePhanLoai.Properties.Columns.Add(col);
            lePhanLoai.EditValue = ((DataTable)lePhanLoai.Properties.DataSource).Rows[0]["ProductGroup_ID"];
            lePhanLoai.Properties.Buttons[1].Click += btnThemNhomhang_ThemHangHoa_Click;

            leDonVi.Properties.TextEditStyle = TextEditStyles.Standard;
            leDonVi.Properties.DataSource    = BUS_DonViTinh.GetDVTDonGian();
            leDonVi.Properties.DisplayMember = "UNIT_Name";
            leDonVi.Properties.ValueMember   = "UNIT_ID";
            col  = new LookUpColumnInfo("UNIT_ID", "Mã");
            col1 = new LookUpColumnInfo("UNIT_Name", "Tên");
            leDonVi.Properties.Columns.Add(col1);
            leDonVi.Properties.Columns.Add(col);
            leDonVi.EditValue = ((DataTable)leDonVi.Properties.DataSource).Rows[0]["UNIT_ID"];
            leDonVi.Properties.Buttons[1].Click += btnThemDV_ThemHangHoa_Click;

            leNCC.Properties.TextEditStyle = TextEditStyles.Standard;
            leNCC.Properties.DataSource    = BUS_NhaCungCap.LayNhaCC();
            leNCC.Properties.DisplayMember = "CustomerName";
            leNCC.Properties.ValueMember   = "Customer_ID";
            col  = new LookUpColumnInfo("Customer_ID", "Mã");
            col1 = new LookUpColumnInfo("CustomerName", "Tên");
            leNCC.Properties.Columns.Add(col1);
            leNCC.Properties.Columns.Add(col);
            leNCC.EditValue = ((DataTable)leNCC.Properties.DataSource).Rows[0]["Customer_ID"];
            leNCC.Properties.Buttons[1].Click += btnThemNCC_ThemHangHoa_Click;

            peHinhAnh.Properties.NullText = "Ảnh";
            peHinhAnh.Click += PeHinhAnh_Click;

            txtMa.TextChanged        += TxtMa_TextChanged;
            txtMaVachNSX.TextChanged += TxtMaVachNSX_TextChanged;

            if (add == true)
            {
                phatSinhMa();
            }
            else
            {
                LoadDuLieuHH();
            }
        }
Beispiel #2
0
        private void Init()
        {
            //Khởi tạo nhân viên bán hàng
            leNhanVienBH.Properties.TextEditStyle = TextEditStyles.Standard;
            leNhanVienBH.Properties.BestFitMode   = BestFitMode.BestFit;
            SetDataSource(leNhanVienBH, BUS_NhanVien.LayNhanVienDonGian(), "EMPLOYEE_Name", "EMPLOYEE_ID");
            leNhanVienBH.Properties.Columns[0].FieldName = "EMPLOYEE_Name";
            leNhanVienBH.Properties.Columns[1].FieldName = "EMPLOYEE_ID";
            //leNhanVienBH.EditValue = ((DataTable)leNhanVienBH.Properties.DataSource).Rows[0]["EMPLOYEE_ID"];

            //Khởi tạo kho xuất
            leKhoXuat.Properties.TextEditStyle = TextEditStyles.Standard;
            leKhoXuat.Properties.BestFitMode   = BestFitMode.BestFit;
            SetDataSource(leKhoXuat, BUS_KhoXuat.LayKhoDonGian(), "STOCK_Name", "STOCK_ID");
            leKhoXuat.Properties.Columns[0].FieldName = "STOCK_Name";
            leKhoXuat.Properties.Columns[1].FieldName = "STOCK_ID";
            //leKhoXuat.EditValue = ((DataTable)leKhoXuat.Properties.DataSource).Rows[0]["STOCK_ID"];

            //Khởi tạo các DateEdit
            deHanTT.EditValue    = DateTime.Today.ToShortDateString();
            deNgayGiao.EditValue = DateTime.Today.ToShortDateString();
            deNgay.EditValue     = DateTime.Today.ToShortDateString();

            //Khởi tạo GridviewControl
            gvMain.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            CreateDataSource();
            gvcMain.DataSource       = dsGcMain.Tables[0];
            gvMain.CellValueChanged += GvMain_CellValueChanged;
            //gvMain.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;

            //Khởi tạo đơn vị tính
            leDonVi.NullText       = "(Chọn)";
            leDonVi.TextEditStyle  = TextEditStyles.Standard;
            leMaHang.TextEditStyle = TextEditStyles.Standard;
            leMaHang.BestFitMode   = BestFitMode.BestFit;
            SetDataSource(leDonVi, BUS_DonViTinh.GetDVTDonGian(), "UNIT_Name", "UNIT_ID");
            leDonVi.Columns.Add(new LookUpColumnInfo("UNIT_Name", "ĐVT"));

            //Khởi tạo Mã hàng
            leMaHang.NullText = "(Chọn)";
            SetDataSource(leMaHang, BUS_HangHoa.LayHangHoaLookupEdit(), "Product_ID", "Product_ID");
            leMaHang.Columns.Add(new LookUpColumnInfo("Product_ID", "Mã hàng"));
            leMaHang.Columns.Add(new LookUpColumnInfo("Product_Name", "Tên hàng"));
            leMaHang.Columns.Add(new LookUpColumnInfo("Quantity", "Tồn kho"));
            leMaHang.Columns.Add(new LookUpColumnInfo("Stock_Name", "Kho hàng"));
            leMaHang.Columns.Add(new LookUpColumnInfo("Unit", "Đơn vị tính"));
            leMaHang.PopupFormMinSize = new System.Drawing.Size(600, 350);

            //Khởi tạo Tên hàng
            leTenHang.NullText = "(Chọn)";
            SetDataSource(leTenHang, BUS_HangHoa.LayHangHoaLookupEdit(), "Product_Name", "Product_ID");
            leTenHang.Columns.Add(new LookUpColumnInfo("Product_ID", "Mã hàng"));
            leTenHang.Columns.Add(new LookUpColumnInfo("Product_Name", "Tên hàng"));
            leTenHang.Columns.Add(new LookUpColumnInfo("Quantity", "Tồn kho"));
            leTenHang.Columns.Add(new LookUpColumnInfo("Stock_Name", "Kho hàng"));
            leTenHang.Columns.Add(new LookUpColumnInfo("Unit", "Đơn vị tính"));
            leTenHang.PopupFormMinSize = new System.Drawing.Size(600, 350);

            calceSoLuong.NullText        = "0";
            calceSoLuong.MaxLength       = 10;
            calceDonGia.NullText         = "0";
            calceDonGia.MaxLength        = 10;
            calceChietKhauTiLe.NullText  = "0";
            calceChietKhauTiLe.MaxLength = 10;
            calceChietKhau.NullText      = "0";
            calceChietKhau.MaxLength     = 10;
            calceThanhToan.NullText      = "0";
            calceThanhToan.MaxLength     = 10;

            List <object> listDKTT = new List <object>
            {
                new { name = "Công nợ" },
                new { name = "Thanh toán ngay" }
            };

            gleDKTT.Properties.DataSource    = listDKTT;
            gleDKTT.Properties.ValueMember   = "name";
            gleDKTT.Properties.DisplayMember = "name";
            LookUpColumnInfo col_t = new LookUpColumnInfo("name", "");

            gleDKTT.Properties.Columns.Add(col_t);
            gleDKTT.EditValue = "Công nợ";

            List <object> listHTTT = new List <object>
            {
                new { ID = 0, name = "Tiền mặt" },
                new { ID = 1, name = "Chuyển khoản" }
            };

            gleHTTT.Properties.DataSource    = listHTTT;
            gleHTTT.Properties.ValueMember   = "name";
            gleHTTT.Properties.DisplayMember = "name";
            col_t = new LookUpColumnInfo("name", "");
            gleHTTT.Properties.Columns.Add(col_t);
            gleHTTT.EditValue = "Tiền mặt";

            //Xử lý

            if (isSale == true)
            {
                //Khởi tạo KH
                leKH.Properties.TextEditStyle = TextEditStyles.Standard;
                leKH.Properties.BestFitMode   = BestFitMode.BestFit;
                SetDataSource(leKH, BUS_KhachHang.LayKhachHangDonGian(), "CustomerName", "Customer_ID");
                leKH.Properties.Columns[0].FieldName = "CustomerName";
                leKH.Properties.Columns[1].FieldName = "Customer_ID";
                leKH.Properties.Buttons[1].Click    += btnThemKH_BaseMH_BH_Click;

                //Khởi tạo Mã KH
                leMaKH.Properties.TextEditStyle = TextEditStyles.Standard;
                leMaKH.Properties.BestFitMode   = BestFitMode.BestFit;
                SetDataSource(leMaKH, BUS_KhachHang.LayKhachHangDonGian(), "Customer_ID", "Customer_ID");
                leMaKH.Properties.Columns[1].FieldName = "CustomerName";
                leMaKH.Properties.Columns[0].FieldName = "Customer_ID";

                //Gán sự kiện cho KH và Mã KH
                leKH.EditValueChanged   += GeKH_EditValueChanged;
                leMaKH.EditValueChanged += GeMaKH_EditValueChanged;

                Text = "Phiếu xuất hàng";
            }
            else
            {
                lcITen.Text            = "Tên NCC";
                lcIMa.Text             = "Mã NCC";
                lcINgayGiao.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                //Khởi tạo NCC
                leKH.Properties.NullText      = "Chọn tên Nhà cung cấp ...";
                leKH.Properties.TextEditStyle = TextEditStyles.Standard;
                leKH.Properties.BestFitMode   = BestFitMode.BestFit;
                SetDataSource(leKH, BUS_NhaCungCap.LayNhaCC(), "CustomerName", "Customer_ID");
                leKH.Properties.Columns[0].FieldName = "CustomerName";
                leKH.Properties.Columns[1].FieldName = "Customer_ID";
                leKH.Properties.Buttons[1].Click    += btnThenNCC_BaseMH_BH_Click;

                //Khởi tạo Mã NCC
                leMaKH.Properties.NullText      = "Chọn mã Nhà cung cấp ...";
                leMaKH.Properties.TextEditStyle = TextEditStyles.Standard;
                leMaKH.Properties.BestFitMode   = BestFitMode.BestFit;
                SetDataSource(leMaKH, BUS_NhaCungCap.LayNhaCC(), "Customer_ID", "Customer_ID");
                leMaKH.Properties.Columns[1].FieldName = "CustomerName";
                leMaKH.Properties.Columns[0].FieldName = "Customer_ID";

                //Gán sự kiện cho NCC và Mã NCC
                leKH.EditValueChanged   += GeKH_EditValueChanged;
                leMaKH.EditValueChanged += GeMaKH_EditValueChanged;

                Text = "Phiếu nhập hàng";

                deNgayGiao.Visible = false;
                lcIKho.Text        = "Kho nhập";
                gvMain.Columns["colChietKhauTiLe"].Visible = false;
                gvMain.Columns["colChietKhau"].Visible     = false;
                gvMain.Columns["colThanhToan"].Visible     = false;
            }
            table = BUS_KhoXuat.GetTonKhoLookup();
            if (add == true)
            {
                phatSinhMa();
            }
            else
            {
                LoadDuLieu();
            }
        }