示例#1
0
        private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int intRow = gridView1.FocusedRowHandle;

            if ((intRow >= 0) && (gridView1.GetRowCellValue(intRow, "PhieuNhapID") != null))
            {
                string strPhieuNhap = gridView1.GetRowCellValue(intRow, "PhieuNhapID").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)
                    {
                        PhieuNhapController.Del(strPhieuNhap);
                        gridControl1.DataSource = PhieuNhapController.GetAllList();
                    }
                    break;

                case "VIEW":
                    PhieuNhap viewItem = PhieuNhapController.GetItem(strPhieuNhap);
                    if (viewItem != null)
                    {
                        frmAddPhieuNhap f = new frmAddPhieuNhap();
                        f.ViewItem  = viewItem;
                        f.forMode   = "view";
                        f.MdiParent = this.MdiParent;
                        f.Show();
                        this.Dispose();
                    }
                    break;

                default:
                    break;
                }
            }
        }
示例#2
0
        private void UcRawImported_Loaded(object sender, RoutedEventArgs e)
        {
            NhaCungCapController nhaCungCap = new NhaCungCapController();
            NguyenLieuController nguyenLieu = new NguyenLieuController();
            PhieuNhapController  phieuNhap  = new PhieuNhapController();

            cbbNhaCungCap.ItemsSource    = nhaCungCap.GetName();
            cbbTenNguyenLieu.ItemsSource = nguyenLieu.GetName();

            cbbNhaCungCap.SelectedIndex = 0;

            btnLuu.IsEnabled = false;
            btnHuy.IsEnabled = false;

            cbbTenNguyenLieu.IsEnabled = false;
            txtSoLuongNhap.IsEnabled   = false;
            dtpHanSuDung.IsEnabled     = false;
            txtGia.IsEnabled           = false;
            txtGhiChu.IsEnabled        = false;

            LoadDSPhieuNhap();

            dgvPhieuNhap.Columns[0].Header = "Tên nguyên liệu";
            dgvPhieuNhap.Columns[1].Header = "Số lượng";
            dgvPhieuNhap.Columns[2].Header = "Hạn sử dụng";
            dgvPhieuNhap.Columns[3].Header = "Giá";
            dgvPhieuNhap.Columns[4].Header = "Ghi chú";
            dgvPhieuNhap.Columns[5].Header = "Tổng tiền";
        }
示例#3
0
        private void SearchDSPhieuNhap(string search)
        {
            PhieuNhapController phieuNhap = new PhieuNhapController();

            dgvDSPhieuNhap.ItemsSource           = phieuNhap.SearchList(search).DefaultView;
            dgvDSPhieuNhap.Columns[0].Visibility = Visibility.Collapsed;
            dgvDSPhieuNhap.SelectedIndex         = 0;
        }
示例#4
0
        private void LoadDSPhieuNhap()
        {
            PhieuNhapController phieuNhap = new PhieuNhapController();

            dgvDSPhieuNhap.ItemsSource           = phieuNhap.GetList().DefaultView;
            dgvDSPhieuNhap.Columns[0].Visibility = Visibility.Collapsed;
            dgvDSPhieuNhap.SelectedIndex         = 0;
        }
示例#5
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            DataView tblDefaultView = PhieuNhapController.GetListRangDate(dateEditStart.DateTime, dateEditEnd.DateTime).DefaultView;

            tblDefaultView.Sort     = "[NgayNhap] DESC";
            gridControl1.DataSource = tblDefaultView;
            gridView1.BestFitColumns();
        }
示例#6
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, "PhieuNhapID").ToString();
                gridControl2.DataSource = PhieuNhapController.GetSanPham(strDonHangID); //DonHangController.GetSanPham(strDonHangID);
                gridView2.ExpandAllGroups();
                gridView2.BestFitColumns();
            }
        }
示例#7
0
        private void toolLuuThem_Click(object sender, EventArgs e)
        {
            ctrl = new PhieuNhapController();

            status = Controll.AddNew;

            txtMaPhieu.Text   = ThamSo.LayMaPhieuNhap().ToString();
            numTongTien.Value = 0;
            numDaTra.Value    = 0;
            numConNo.Value    = 0;
            ctrlMaSP.HienThiChiTietPhieuNhap(txtMaPhieu.Text, dataGridView);
            this.Allow(true);
        }
        private void toolIn_Click(object sender, EventArgs e)
        {
            DataRowView row = (DataRowView)bindingNavigator.BindingSource.Current;

            if (row != null)
            {
                PhieuNhapController ctrlPN = new PhieuNhapController();
                String ma_phieu            = row["ID"].ToString();
                CuahangNongduoc.BusinessObject.PhieuNhap ph = ctrlPN.LayPhieuNhap(ma_phieu);
                frmInPhieuNhap PhieuNhap = new frmInPhieuNhap(ph);
                PhieuNhap.Show();
            }
        }
示例#9
0
        private void BtnLuuPhieuNhap_Click(object sender, RoutedEventArgs e)
        {
            if (ctpn.Count > 0)
            {
                NhaCungCapController nhaCungCap = new NhaCungCapController();
                PhieuNhapController  phieuNhap  = new PhieuNhapController();
                NguyenLieuController nguyenLieu = new NguyenLieuController();
                int      mancc    = nhaCungCap.NameToId(cbbNhaCungCap.Text);
                DateTime ngayNhap = DateTime.Now;
                int      tongTien = Convert.ToInt32(txtTongTien.Text);

                try
                {
                    phieuNhap.Create(manv, mancc, ngayNhap, txtGhiChuPN.Text, tongTien);

                    int maPN = phieuNhap.GetLastId();

                    foreach (var item in ctpn)
                    {
                        int      maNL = nguyenLieu.NameToId(item.TenNL);
                        DateTime hsd  = Convert.ToDateTime(item.HanSuDung);
                        phieuNhap.CreateDetails(maPN, maNL, hsd, item.SoLuongNhap, item.Gia, item.GhiChu);
                    }

                    MessageBox.Show("Lưu phiếu nhập thành công!", "Thông báo!", MessageBoxButton.OK, MessageBoxImage.Information);

                    ctpn.Clear();
                    cbbTenNguyenLieu.IsEnabled     = false;
                    cbbTenNguyenLieu.SelectedIndex = 0;
                    txtSoLuongNhap.IsEnabled       = false;
                    txtSoLuongNhap.Text            = "";
                    dtpHanSuDung.IsEnabled         = false;
                    dtpHanSuDung.SelectedDate      = DateTime.Now;
                    txtGia.IsEnabled    = false;
                    txtGia.Text         = "";
                    txtGhiChu.IsEnabled = false;
                    txtGhiChu.Text      = "";

                    LoadDSPhieuNhap();

                    txtGhiChuPN.Text = "";
                    tongTien         = 0;
                    txtTongTien.Text = tongTien.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        public ucImportedDetails(int id)
        {
            InitializeComponent();
            PhieuNhapController  phieuNhap = new PhieuNhapController();
            NhaCungCapController ncc       = new NhaCungCapController();

            dgvPhieuNhapDetails.ItemsSource = phieuNhap.GetDetails(id).DefaultView;
            int nccid = phieuNhap.GetDistributorId(id);

            txtNhaCungCap.Text = ncc.IdToName(nccid);
            txtGhiChuPN.Text   = phieuNhap.GetNote(id);
            txtTongTien.Text   = phieuNhap.GetTotal(id);

            btnClose.Click += BtnClose_Click;
        }
示例#11
0
        private void frmAddPhieuNhap_Load(object sender, EventArgs e)
        {
            //KhoiTaoDuLieuSearch();
            //txtSanPham.Properties.DataSource = SanPhamController.GetActiveList();
            KhoiTaoLuoi();
            KhoiTaoDSNhaCungCap();
            //------------------------------------------
            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;



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

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

            //Chế độ view đơn hang
            if ((forMode.ToUpper().Equals("VIEW")) && (ViewItem != null))
            {
                txtMaPhieu.Text          = ViewItem.PhieuNhapID;
                dateEditNgayBan.DateTime = ViewItem.NgayNhap;
                if (ViewItem.NhaCungCapID != null)
                {
                    lookUpEditNhaCungCap.EditValue = ViewItem.NhaCungCapID;
                }
                txtNhanVien.Text   = ViewItem.NhanVienID;
                txtGhiChu.Text     = ViewItem.GhiChu;
                txtTienHang.Value  = ViewItem.TienHang;
                txtThanhToan.Value = ViewItem.ThanhToan;
                txtConNo.Value     = ViewItem.ConNo;

                //lay danh sach san pham
                gridControl1.DataSource = PhieuNhapController.GetSanPham(ViewItem.PhieuNhapID);

                btnSave.Enabled = false;
            }
        }
示例#12
0
        private void toolSavePrint_Click(object sender, EventArgs e)
        {
            if (status != Controll.Normal)
            {
                MessageBox.Show("Vui lòng lưu lại Phiếu nhập hiện tại!", "Phieu Nhap", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                String ma_phieu = txtMaPhieu.Text;

                PhieuNhapController ctrlPN = new PhieuNhapController();

                CuahangNongduoc.BusinessObject.PhieuNhap ph = ctrlPN.LayPhieuNhap(ma_phieu);

                frmInPhieuNhap PhieuNhap = new frmInPhieuNhap(ph);

                PhieuNhap.Show();
            }
        }
示例#13
0
        private void Save()
        {
            PhieuNhap itemSave = new PhieuNhap();

            //thong tin ban hang
            itemSave.PhieuNhapID = PhieuNhapController.TaoMaPhieuNhap("PN", 10);
            itemSave.NgayNhap    = dateEditNgayBan.DateTime;
            if (lookUpEditNhaCungCap.EditValue != null)
            {
                itemSave.NhaCungCapID  = lookUpEditNhaCungCap.EditValue.ToString();
                itemSave.TenNhaCungCap = lookUpEditNhaCungCap.Text;
            }
            itemSave.MaPhieuNCC  = txtPhieuNhaCC.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.ThanhToan = txtThanhToan.Value;
            itemSave.ConNo     = txtConNo.Value;
            //lay thong tin chi tiet don hang
            List <PhieuNhapChiTiet> PhieuNhapItems = new List <PhieuNhapChiTiet>();

            if (tblDonHangChiTiet != null)
            {
                foreach (DataRow item in tblDonHangChiTiet.Rows)
                {
                    PhieuNhapChiTiet newitem = new PhieuNhapChiTiet();
                    newitem.PhieuNhapID = itemSave.PhieuNhapID;
                    newitem.SanPhamID   = item["SanPhamID"].ToString();
                    newitem.TenSanPham  = item["TenSanPham"].ToString();
                    newitem.Size        = item["Size"].ToString();
                    newitem.SoLuong     = Convert.ToInt32(item["SoLuong"].ToString());
                    newitem.DonGia      = Convert.ToDecimal(item["DonGia"].ToString());
                    newitem.CreateDate  = DateTime.Now;
                    //newitem.TonKho = SanPhamController.GetTonKho(newitem.SanPhamID);
                    PhieuNhapItems.Add(newitem);
                }
            }
            PhieuNhapController.Add(itemSave, PhieuNhapItems);
        }
示例#14
0
        public ucLapPhieuNhapHang()
        {
            InitializeComponent();
            sanPham    = new SanPhamController();
            nhacungcap = new NhacungcapController();
            phieuNhap  = new PhieuNhapController();

            DataTable dt;

            dt = sanPham.GetDanhSachDonVi();
            foreach (DataRow row in dt.Rows)
            {
                cbbDonVi.Items.Add(row[0]);
            }
            dt = nhacungcap.GetAllNhacungcap();
            foreach (DataRow row in dt.Rows)
            {
                cbbTenNhaCC.Items.Add(row[1]);
            }
        }
示例#15
0
        void ThemMoi()
        {
            DataRow row = ctrl.NewRow();

            row["ID"]              = txtMaPhieu.Text;
            row["NGAY_NHAP"]       = dtNgayNhap.Value.Date;
            row["TONG_TIEN"]       = numTongTien.Value;
            row["ID_NHA_CUNG_CAP"] = cmbNhaCungCap.SelectedValue;
            row["DA_TRA"]          = numDaTra.Value;
            row["CON_NO"]          = numConNo.Value;
            ctrl.Add(row);

            PhieuNhapController ctrlPN = new PhieuNhapController();

            if (ctrlPN.LayPhieuNhap(txtMaPhieu.Text) != null)
            {
                MessageBox.Show("Mã Phiếu nhập này đã tồn tại !", "Phieu Nhap", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ThamSo.LaSoNguyen(txtMaPhieu.Text))
            {
                long so = Convert.ToInt64(txtMaPhieu.Text);
                if (so >= ThamSo.LayMaPhieuNhap())
                {
                    ThamSo.GanMaPhieuNhap(so + 1);
                }
            }

            ctrl.Save();
            ctrlMaSP.Save();

            SanPhamController ctrlSP = new SanPhamController();

            foreach (DataGridViewRow view in dataGridView.Rows)
            {
                ctrlSP.CapNhatGiaNhap(Convert.ToString(view.Cells["colSanPham"].Value),
                                      Convert.ToInt64(view.Cells["colDonGiaNhap"].Value),
                                      Convert.ToInt64(view.Cells["colSoLuong"].Value));
            }
        }
示例#16
0
 public frmNhapHang(PhieuNhapController ctrlPN)
     : this()
 {
     this.ctrl = ctrlPN;
     status    = Controll.Normal;
 }