Ejemplo n.º 1
0
        private void btnThem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridView grv = gvcMain.Views[0] as GridView;

            while (grv.RowCount > 1)
            {
                grv.DeleteRow(0);
                leMaHang.DataSource  = BUS_HangHoa.LayHangHoaLookupEdit();
                leTenHang.DataSource = BUS_HangHoa.LayHangHoaLookupEdit();
            }
        }
Ejemplo n.º 2
0
        private void Init()
        {
            QuyenNguoiDung.LayQuyenNguoiDungTheoChucNang("btnTonKho");
            if (QuyenNguoiDung.Them == false)
            {
                btnThem.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
            if (QuyenNguoiDung.Sua == false)
            {
                btnSua.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
            if (QuyenNguoiDung.Xoa == false)
            {
                btnXoa.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }

            gcMain.DataSource = BUS_HangHoa.LayHangHoaLookupEdit();

            gvMain.Columns[0].FieldName = "Product_ID";
            gvMain.Columns[1].FieldName = "Product_Name";
            gvMain.Columns[4].FieldName = "Quantity";
            gvMain.Columns[2].FieldName = "Stock_Name";
            gvMain.Columns[3].FieldName = "Unit";
            gvMain.Columns[5].FieldName = "Product_Group_ID";
            gvMain.Columns[6].FieldName = "Active";

            btnThem.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            btnSua.Visibility  = DevExpress.XtraBars.BarItemVisibility.Never;
            btnXoa.Visibility  = DevExpress.XtraBars.BarItemVisibility.Never;

            gcMain.UseEmbeddedNavigator = true;
            gcMain.EmbeddedNavigator.Buttons.Append.Visible     = false;
            gcMain.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
            gcMain.EmbeddedNavigator.Buttons.Edit.Visible       = false;
            gcMain.EmbeddedNavigator.Buttons.EndEdit.Visible    = false;
            gcMain.EmbeddedNavigator.Buttons.Remove.Visible     = false;

            gvMain.IndicatorWidth          = 45;
            gvMain.CustomDrawRowIndicator += GvMain_CustomDrawRowIndicator;

            btnLamMoi.ItemClick += BtnLamMoi_ItemClick;
        }
Ejemplo n.º 3
0
 private void BtnLamMoi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     gcMain.DataSource = BUS_HangHoa.LayHangHoaLookupEdit();
 }
Ejemplo n.º 4
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();
            }
        }