Exemplo n.º 1
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            if (tb_TenLoaiKH.Text == "")
            {
                MessageBox.Show("Vui lòng nhập tên loại khách hàng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            BLLResult res = new BLLResult();

            if (num_TriGiaHoaDonToiThieu.Value < 1000)
            {
                MessageBox.Show("Mốc tối thiếu phải từ 1000000 VNĐ trở lên!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (num_PhanTramGiam.Value == 0)
            {
                MessageBox.Show("Phần trăm giảm phải lớn hơn 0%!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            res = _LoaiKhachHang.Insert(tb_TenLoaiKH.Text.Trim(), num_TriGiaHoaDonToiThieu.Value, num_PhanTramGiam.Value);
            _LoaiKhachHang.MakeMessageBox(res);
            if (res._Code == (int)BLLResultType.S_ADD)
            {
                try { mainform.frm_khachhang.IsReset = true; } catch {}
            }

            Reset();
        }
Exemplo n.º 2
0
        private void btn_XoaHoaDon_Click(object sender, EventArgs e)
        {
            if ((new BLL_User()).IsUser())
            {
                MessageBox.Show("Chức năng dành cho Admin, User thường không sử dụng được!", "Giới hạn quyền sử dụng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            BLLResult res = new BLLResult();

            try
            {
                int[] selectedindex = gridView1.GetSelectedRows();
                var   tt            = gridView1.GetRow(selectedindex[0]);
                res = (new BLL_HoaDonMuaHang()).Delete(((DLL.HoaDonMuaHang)tt).MaHDMH.Trim());
                _CTHDMH.MakeMessageBox(res);
                if (res._Code == (int)BLLResultType.S_DELETE)
                {
                    _Orginal = (new BLL_HoaDonMuaHang()).GetList();
                    LoadGrid(_Orginal);
                    try { mainform.frm_muahang.IsReset = true; } catch { }
                }
            }
            catch (Exception)
            {
                _CTHDMH.MakeMessageBox(new BLLResult("Vui lòng chọn hóa đơn để xóa!"));
            }
        }
Exemplo n.º 3
0
        public static BLLResult DataBaseResultToBLLResult(DAL.Extensions.DataBaseResult dataBaseResult)
        {
            BLLResult result = BLLResult.Error;

            switch (dataBaseResult)
            {
            case DAL.Extensions.DataBaseResult.Success:
                result = BLLResult.Success;
                break;

            case DAL.Extensions.DataBaseResult.AlreadyFound:
                result = BLLResult.AlreadyFound;
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                result = BLLResult.Referanced;
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                result = BLLResult.NotFound;
                break;

            case DAL.Extensions.DataBaseResult.Error:
                result = BLLResult.Error;
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                result = BLLResult.ServerDisable;
                break;

            default:
                throw new ArgumentOutOfRangeException("dataBaseResult", dataBaseResult, null);
            }
            return(result);
        }
Exemplo n.º 4
0
        // [OK]
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if ((new BLL_User()).IsUser())
            {
                MessageBox.Show("Chức năng dành cho Admin, User thường không sử dụng được!", "Giới hạn quyền sử dụng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            BLLResult res = new BLLResult();

            try
            {
                int    rowindex = grid_Filter.SelectedCells[0].RowIndex;
                string mahd     = grid_Filter.Rows[rowindex].Cells[0].Value.ToString().Trim();
                if (cb_ThietLapTrangThai.Text == "Đã Giao")// Trừ công nợ cho KH
                {
                    int    tongtien = Int32.Parse(grid_Filter.Rows[rowindex].Cells[11].Value.ToString().Trim());
                    string tenkh    = grid_Filter.Rows[rowindex].Cells[6].Value.ToString().Trim();
                    res = _KhachHang.CongNoPlus(-tongtien, tenkh);
                    if (res._Code != (int)BLLResultType.SUCCESS)
                    {
                        _KhachHang.MakeMessageBox(res);
                        return;
                    }
                }
                res = _HoaDonBanHang.SetTrangThai(cb_ThietLapTrangThai.Text, mahd);
                if (res._Code == (int)BLLResultType.SUCCESS) // Thành công
                {
                    MessageBox.Show("Thiết lập thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    try { mainform.frm_khachhang.IsReset = true; } catch { }
                    RecordThongKeBanHang record = new RecordThongKeBanHang();
                    foreach (RecordThongKeBanHang vari in _ListOrginal)
                    {
                        if (vari.MaHDBH == mahd)
                        {
                            record = vari;
                            _ListOrginal.Remove(vari);
                            break;
                        }
                    }
                    record.TrangThai = cb_ThietLapTrangThai.Text;
                    _ListOrginal.Add(record);
                    Reset();
                }
            }
            catch (Exception)
            {
                _HoaDonBanHang.MakeMessageBox(res);
            }
        }
Exemplo n.º 5
0
 private void btn_XoaDVT_Click(object sender, EventArgs e)
 {
     try
     {
         BLLResult res = _DVT.Delete(maDVT, false);
         _DVT.MakeMessageBox(res);
         if (res._Code == (int)BLLResultType.S_DELETE)
         {
             UpdateGridDVT();
             try { mainform.frm_vatlieu.IsReset = true; } catch { }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Vui lòng chọn đơn vị tính để xóa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 6
0
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     try
     {
         BLLResult res = _LoaiKhachHang.Delete(maLoaiKH, false);
         _LoaiKhachHang.MakeMessageBox(res);
         if (res._Code == (int)BLLResultType.S_DELETE)
         {
             try { try { mainform.frm_khachhang.IsReset = true; } catch {} } catch {}
             Reset();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Vui lòng chọn loại khách hàng để xóa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 7
0
        private void btn_ThemDVT_Click(object sender, EventArgs e)
        {
            if (tb_DonViTinh.Text == "")
            {
                _DVT.MakeMessageBox(new BLLResult("Vui lòng nhập đơn vị tính mới!"));
                return;
            }


            BLLResult res = _DVT.Insert(tb_DonViTinh.Text.Trim());

            _DVT.MakeMessageBox(res);
            if (res._Code == (int)BLLResultType.S_ADD)
            {
                UpdateGridDVT();
                try { mainform.frm_vatlieu.IsReset = true; } catch { }
            }
        }
Exemplo n.º 8
0
        // [Thêm]
        private void btn_Them_Click(object sender, EventArgs e)
        {
            if (tb_TenLoaiKH.Text == "")
            {
                MessageBox.Show("Vui lòng nhập tên loại khách hàng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            BLLResult res = new BLLResult();

            // res = _LoaiKhachHang.Insert(tb_TenLoaiKH.Text.Trim(), num_SoLanMuaToiThieu.Value, num_TriGiaHoaDonToiThieuMoiLanMua.Value, num_PhanGiamGiamLanMuaCuoi.Value);
            _LoaiKhachHang.MakeMessageBox(res);
            if (res._Code == (int)BLLResultType.S_ADD)
            {
                try { mainform.frm_khachhang.IsReset = true; } catch {}
            }

            Reset();
        }
Exemplo n.º 9
0
 private void btn_XoaHoaDon_Click(object sender, EventArgs e)
 {
     if ((new BLL_User()).IsUser())
     {
         MessageBox.Show("Chức năng dành cho Admin, User thường không sử dụng được!", "Giới hạn quyền sử dụng", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (main == null)
     {
         BLLResult res = _HoaDon.Delete(_MaHDBH.Trim(), false);
         _HoaDon.MakeMessageBox(res);
     }
     else // gọi từ form thống kê bán hàng
     {
         main.XoaHoaDon(_MaHDBH.Trim());
     }
     this.Close();
 }
Exemplo n.º 10
0
 private void btn_Xoa_Click(object sender, EventArgs e)
 {
     try
     {
         int[]     selectedindex = gridView1.GetSelectedRows();
         var       loai          = gridView1.GetRow(selectedindex[0]);
         BLLResult res           = _LoaiKhachHang.Delete(((DLL.LoaiKhachHang)loai).MaLoaiKH.ToString().Trim(), false);
         _LoaiKhachHang.MakeMessageBox(res);
         if (res._Code == (int)BLLResultType.S_DELETE)
         {
             try { try { mainform.frm_khachhang.IsReset = true; } catch {} } catch {}
             Reset();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Vui lòng chọn loại khách hàng để xóa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 11
0
        public bool XoaHoaDon(string MaHD)
        {
            MaHD = MaHD.Trim();
            BLLResult res = new BLLResult();

            res = _HoaDonBanHang.Delete(MaHD, false);
            _HoaDonBanHang.MakeMessageBox(res);
            if (res._Code == (int)BLLResultType.S_DELETE) // Xóa thành công
            {
                foreach (RecordThongKeBanHang vari in _ListOrginal)
                {
                    if (vari.MaHDBH == MaHD)
                    {
                        _ListOrginal.Remove(vari);
                        break;
                    }
                }
                Reset();
                return(true);
            }
            return(false);
        }
Exemplo n.º 12
0
        // Bấm nút [Xóa] :
        private void btn_Xoa_Click(object sender, EventArgs e)
        {
            if ((new BLL_User()).IsUser())
            {
                MessageBox.Show("Chức năng dành cho Admin, User thường không sử dụng được!", "Giới hạn quyền sử dụng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            te_TimKiemVatLieu.Text = "";

            if (gridView3.SelectedRowsCount != 1)
            {
                ResetSearch();
                return;
            }

            int[]             selectedindex  = gridView3.GetSelectedRows();
            DLL.HoaDonMuaHang hoadondangchon = (QLVLXD.DLL.HoaDonMuaHang)gridView3.GetRow(selectedindex[0]);

            BLLResult result = _BLL_HoaDonMuaHang.Delete(lb_MaHDMH.Text.Trim());

            if (result._Code != (int)BLLResultType.S_DELETE)
            {
                _BLL_CTHoaDonMuaHang.MakeMessageBox(result);
                return;
            }

            ResetForNewInsert();

            _List_HoaDonMuaHang.Clear();
            _List_HoaDonMuaHang = _BLL_HoaDonMuaHang.GetList();

            grid_DanhSachHoaDonMuaHang.DataSource = null;
            grid_DanhSachHoaDonMuaHang.DataSource = _List_HoaDonMuaHang;

            ResetSearch();
            try { mainform.frm_thongkemuahang.IsReset = true; } catch { }
            MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 13
0
        private void btn_Xoa_Click(object sender, EventArgs e)
        {
            if (IsAddNew)
            {
                return;
            }

            BLLResult result = _BLL_VatLieu.Delete(lb_MaVatLieu.Text.Trim(), false);

            if (result._Code != (int)BLLResultType.NOT_DELETE)
            {
                _BLL_NhaCungCap.MakeMessageBox(result);
            }

            if (result._Code == (int)BLLResultType.S_DELETE)
            {
                LoadGridView();
                ResetForNewInsert();
                try { mainform.frm_banhang.IsReset = true; } catch {}
                try { mainform.frm_muahang.IsReset = true; } catch {}
            }
        }
Exemplo n.º 14
0
        private void btn_XoaHoaDon_Click(object sender, EventArgs e)
        {
            if ((new BLL_User()).IsUser())
            {
                MessageBox.Show("Chức năng dành cho Admin, User thường không sử dụng được!", "Giới hạn quyền sử dụng", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            BLLResult res = new BLLResult();

            try
            {
                res = (new BLL_HoaDonMuaHang()).Delete(_HDMH.MaHDMH.Trim());
                (new BLL_CTHoaDonBanHang()).MakeMessageBox(res);
                if (res._Code == (int)BLLResultType.S_DELETE)
                {
                    main.Reset();
                    Close();
                }
            }
            catch (Exception)
            {
            }
        }