Exemplo n.º 1
0
        private void btnChon_Click(object sender, EventArgs e)
        {
            if (lookUpEditKhachHang.EditValue != null)
            {
                DataTable tblKH = null;
                tblKH = DonHangController.LayDonHangConNo_KhachHang(lookUpEditKhachHang.EditValue.ToString());
                tblKH.Columns.Add(new DataColumn("Chon", typeof(bool)));
                foreach (DataRow item in tblKH.Rows)
                {
                    item["Chon"] = false;
                }
                gridControl1.DataSource = tblKH;

                //-----------------
                KhachHang iKhachHang = null;
                iKhachHang = KhachHangController.GetItem(lookUpEditKhachHang.EditValue.ToString());
                if (iKhachHang != null)
                {
                    txtKhachHangID.Text    = iKhachHang.KhachHangID;
                    txtTenKhachHang.Text   = iKhachHang.TenKhachHang;
                    calcEditTongTien.Value = iKhachHang.TongTienHang;
                    calcEditConNo.Value    = iKhachHang.CongNo;
                    txtSoDienThoai.Text    = iKhachHang.SoDienThoai;
                }

                strTrangThai = "add";
                DieuKhienTrangThai();
            }
        }
Exemplo n.º 2
0
        private void buttonEdit1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)// user clcik enter
            {
                string strDonHangID = txtDonHangID.Text.Trim();
                itemDonHang = DonHangController.GetItem(strDonHangID);
                if (itemDonHang != null)
                {
                    txtNgayBan.DateTime   = itemDonHang.NgayBan;
                    txtNhanVien.Text      = itemDonHang.TenNhanVien;
                    txtTongTien.EditValue = itemDonHang.TongCong;
                    txtGiamGia.EditValue  = itemDonHang.GiamGia;
                    txtTienTT.EditValue   = itemDonHang.ThanhToan;
                    txtTenKhachHang.Text  = itemDonHang.TenKhachHang;
                    //txtDiaChi.Text = itemDonHang.di

                    tblDS = DonHangController.GetSanPham(strDonHangID);
                    tblDS.Columns.Add(new DataColumn("SLTraLai", typeof(int)));
                    tblDS.Columns.Add(new DataColumn("DonGiaTra", typeof(int)));
                    foreach (DataRow item in tblDS.Rows)
                    {
                        item["SLTraLai"]  = 0;
                        item["DonGiaTra"] = Convert.ToDecimal(item["DonGia"].ToString());
                    }
                    gridControl1.DataSource = tblDS;
                    bandedGridView1.BestFitColumns();
                    txtDonHangID.Enabled = false;
                }
            }
        }
Exemplo n.º 3
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            DataTable TblData = DonHangController.TraCuuChiTietDonHang(dateEditStart.DateTime, dateEditEnd.DateTime);

            gridControl1.DataSource = TblData;
            gridView1.BestFitColumns();
        }
Exemplo n.º 4
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            DataView tblDefaultView = DonHangController.GetListRangDate(dateEditStart.DateTime.Date, dateEditEnd.DateTime).DefaultView;

            tblDefaultView.Sort     = "[NgayBan] DESC";
            gridControl1.DataSource = tblDefaultView;
            gridView1.BestFitColumns();
        }
Exemplo n.º 5
0
        private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            gridControl2.DataSource = null;
            int intSelectRow = gridView1.FocusedRowHandle;

            if ((intSelectRow >= 0) && (intSelectRow < gridView1.RowCount))
            {
                string strDonHangID = gridView1.GetRowCellValue(intSelectRow, "DonHangID").ToString();
                gridControl2.DataSource = DonHangController.GetSanPham(strDonHangID);
                gridView2.ExpandAllGroups();
                gridView2.BestFitColumns();
            }
        }
Exemplo n.º 6
0
        private void frmDonHang_Load(object sender, EventArgs e)
        {
            KhoiTaoLuoi();
            txtSearchDonHang.Properties.NullValuePrompt = "nhập mã đơn hàng/tên khách hàng/số điện thoại để tìm kiếm";
            //TextEdit.Properties.NullValuePrompt
            dateEditStart.DateTime = DateTime.Now;
            dateEditEnd.DateTime   = dateEditStart.DateTime;
            DataView tblDefaultView = DonHangController.GetListRangDate(dateEditStart.DateTime, dateEditEnd.DateTime).DefaultView;

            tblDefaultView.Sort     = "[NgayBan] DESC";
            gridControl1.DataSource = tblDefaultView;
            gridView1.BestFitColumns();
        }
Exemplo n.º 7
0
        private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int intRow = gridView1.FocusedRowHandle;

            if ((intRow >= 0) && (gridView1.GetRowCellValue(intRow, "DonHangID") != null))
            {
                string strDonHangID = gridView1.GetRowCellValue(intRow, "DonHangID").ToString();
                switch (e.Button.Caption.ToUpper())
                {
                case "PRINT":
                    PhieuBanHang rp = new PhieuBanHang();
                    rp.SetDataSource(reportsController.prtDonHang(strDonHangID));
                    rp.Refresh();
                    ThongTinShop shop = ThongTinShopController.GetItem();
                    rp.SetParameterValue("TenShop", shop.TenShop);
                    rp.SetParameterValue("DiaChi", shop.DiaChi);
                    rp.SetParameterValue("SoDienThoai", shop.SoDienThoai);
                    rp.SetParameterValue("WebSite", shop.website);
                    frmViewReports fReport = null;
                    foreach (Form item in MdiChildren)
                    {
                        if (item.GetType() == typeof(frmViewReports))
                        {
                            fReport = (item as frmViewReports);
                            fReport.crystalReportViewer1.ReportSource = rp;
                            fReport.Activate();
                            return;
                        }
                    }
                    fReport = new frmViewReports();
                    fReport.crystalReportViewer1.ReportSource = rp;
                    fReport.MdiParent = this.MdiParent;
                    fReport.Show();
                    break;

                case "DEL":
                    if (MessageBox.Show("Bạn muốn xóa đơn hàng này", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        DonHangController.Del(strDonHangID);
                        gridControl1.DataSource = DonHangController.GetAllList();
                    }
                    break;

                case "VIEW":
                    DonHang viewItem = DonHangController.GetItem(strDonHangID);
                    if (viewItem != null)
                    {
                        frmAddDonHang f = new frmAddDonHang();
                        f.ViewItem  = viewItem;
                        f.forMode   = "view";
                        f.MdiParent = this.MdiParent;
                        f.Show();
                        this.Dispose();
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 8
0
        private void frmAddDonHang_Load(object sender, EventArgs e)
        {
            //KhoiTaoDuLieuSearch();
            //txtSearch.Properties.DataSource = SanPhamController.GetActiveList();
            //txtSearch.Properties.DisplayMember = "SanPhamID";
            //txtSearch.Properties.ValueMember = "SanPhamID";
            txtSanPham.Properties.NullValuePrompt = "Scan mã sản phẩm vào đây";

            KhoiTaoLuoi();
            KhoiTaoDSKhachHang();
            //------------------------------------------
            dateEditNgayBan.DateTime        = DateTime.Now;
            txtNhanVien.Text                = Utility.NguoiSuDung.NguoiDungID;
            txtNhanVien.Properties.ReadOnly = true;
            txtMaPhieu.Properties.ReadOnly  = true;


            txtTienHang.Properties.ReadOnly = true;
            txtTienHang.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtTienHang.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtTienHang.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtTong.Properties.ReadOnly = true;
            txtTong.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtTong.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtTong.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtConNo.Properties.ReadOnly = true;
            txtConNo.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtConNo.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtConNo.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtGiamGia.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtGiamGia.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtGiamGia.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtThanhToan.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtThanhToan.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtThanhToan.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtKhachDua.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtKhachDua.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtKhachDua.Properties.Mask.UseMaskAsDisplayFormat = true;

            txtTienThua.Properties.DisplayFormat.FormatType    = DevExpress.Utils.FormatType.Numeric;
            txtTienThua.Properties.DisplayFormat.FormatString  = "### ### ##0";
            txtTienThua.Properties.Mask.UseMaskAsDisplayFormat = true;
            txtTienThua.Properties.ReadOnly = true;



            //Chế độ view đơn hang
            if ((forMode.ToUpper().Equals("VIEW")) && (ViewItem != null))
            {
                txtMaPhieu.Text          = ViewItem.DonHangID;
                dateEditNgayBan.DateTime = ViewItem.NgayBan;
                if (ViewItem.KhachHangID != null)
                {
                    lookUpEditKhachHang.EditValue = ViewItem.KhachHangID;
                }
                txtNhanVien.Text   = ViewItem.NhanVienID;
                txtGhiChu.Text     = ViewItem.GhiChu;
                txtTienHang.Value  = ViewItem.TienHang;
                txtGiamGia.Value   = ViewItem.GiamGia;
                txtTong.Value      = ViewItem.TongCong;
                txtThanhToan.Value = ViewItem.ThanhToan;
                txtConNo.Value     = ViewItem.ConNo;
                txtKhachDua.Value  = ViewItem.KhachDua == null ? 0 :(decimal)ViewItem.KhachDua;
                txtTienThua.Value  = ViewItem.TienThua == null ? 0 : (decimal)ViewItem.TienThua;

                //lay danh sach san pham
                DataTable tblTemp = DonHangController.GetSanPham(ViewItem.DonHangID);
                //KhoiTaoTableDonHangChiTiet();
                foreach (DataRow item in tblTemp.Rows)
                {
                    tblDonHangChiTiet.Rows.Add(item["SanPhamID"].ToString(),
                                               item["TenSanPham"].ToString(), Convert.ToInt32(item["SoLuong"].ToString()),
                                               Convert.ToInt32(item["DonGia"].ToString()));
                }
                gridControl1.DataSource = tblDonHangChiTiet;// DonHangController.GetSanPham(ViewItem.DonHangID);
                btnSave.Enabled         = false;
            }
            CapNhatTrangThai();


            btnEdit.Enabled = false; //18/12/2015 ; khóa lại ko cho sauwr sau khi đã lưu đơn hàng.
        }
Exemplo n.º 9
0
        private void Save()
        {
            string strMaDonHang = string.Empty;

            using (TransactionScope scope = new TransactionScope())
            {
                DonHang itemSave = new DonHang();
                //kiem tra xem co phai nguoi dung dang sua don hang hay khong
                if (forMode.ToUpper().Equals("EDIT"))//dang sua don hang, phai xu ly xoa don hang cu
                {
                    string strDonHangID = txtMaPhieu.Text;
                    DonHangController.Del(strDonHangID);
                    itemSave.DonHangID  = strDonHangID;
                    itemSave.NgayBan    = dateEditNgayBan.DateTime;
                    itemSave.LastUpdate = DateTime.Now;//ngay sua don hang
                }
                else
                {
                    itemSave.DonHangID = DonHangController.TaoMaDonHang("EX", 10);
                    itemSave.NgayBan   = dateEditNgayBan.DateTime;
                }
                strMaDonHang = itemSave.DonHangID;
                //thong tin ban hang
                if (lookUpEditKhachHang.EditValue != null)
                {
                    itemSave.KhachHangID  = lookUpEditKhachHang.EditValue.ToString();
                    itemSave.TenKhachHang = lookUpEditKhachHang.Text;
                }
                itemSave.GhiChu      = txtGhiChu.Text;
                itemSave.NhanVienID  = txtNhanVien.Text;
                itemSave.TenNhanVien = Utility.NguoiSuDung.TenNguoiDung;
                itemSave.LastUpdate  = DateTime.Now;
                //thong tin thanh toan
                itemSave.TienHang  = txtTienHang.Value;
                itemSave.GiamGia   = txtGiamGia.Value;
                itemSave.TongCong  = txtTong.Value;
                itemSave.ThanhToan = txtThanhToan.Value;
                itemSave.ConNo     = txtConNo.Value;

                itemSave.KhachDua = txtKhachDua.Value;
                itemSave.TienThua = txtTienThua.Value;
                //lay thong tin chi tiet don hang
                List <DonHangChiTiet> DonHangItems = new List <DonHangChiTiet>();
                if (tblDonHangChiTiet != null)
                {
                    foreach (DataRow item in tblDonHangChiTiet.Rows)
                    {
                        DonHangChiTiet newitem = new DonHangChiTiet();
                        newitem.DonHangID  = itemSave.DonHangID;
                        newitem.SanPhamID  = item["SanPhamID"].ToString();
                        newitem.TenSanPham = item["TenSanPham"].ToString();
                        newitem.Size       = item["Size"].ToString().ToUpper();
                        newitem.SoLuong    = Convert.ToInt32(item["SoLuong"].ToString());
                        newitem.DonGia     = Convert.ToDecimal(item["DonGia"].ToString());
                        //newitem.TonKho = SanPhamController.GetTonKho(newitem.SanPhamID);
                        DonHangItems.Add(newitem);
                    }
                }
                DonHangController.Add(itemSave, DonHangItems);
                scope.Complete();
            }

            if (MessageBox.Show("Bạn có muốn in Bill luôn không", "Xác Nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Print_Bill(strMaDonHang);
            }
        }