Beispiel #1
0
        private void bt_xoa_Click(object sender, EventArgs e)
        {
            int currentRowIndex = data_tiepnhan.CurrentCellAddress.Y;// 'current row selected

            //'Verify that indexing OK
            if (-1 < currentRowIndex && currentRowIndex < data_tiepnhan.RowCount)
            {
                HoSoDTO hs = new HoSoDTO();
                hs.Mahs = int.Parse(tb_ma.Text);

                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = hsBus.xoa(hs);
                if (kq == false)
                {
                    MessageBox.Show("Xóa hồ sơ thất bại. Vui lòng kiểm tra lại dũ liệu");
                }
                else
                {
                    MessageBox.Show("Xóa hồ sơ thành công");
                    this.loadData_Vao_GridView();
                }
            }
            CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_tiepnhan.DataSource];

            myCurrencyManager.Refresh();
        }
Beispiel #2
0
        private void confirm_btn_Click(object sender, EventArgs e)
        {
            hsBus = new HoSoBUS();
            if (function.Text == "Thêm")
            {
                HoSoDTO hs = new HoSoDTO();
                hs.ma        = int.Parse(maHoSo_Txt.Text);
                hs.tenHoSo   = tenHoSo_Txt.Text;
                hs.loai      = int.Parse(loaiHoSo_Txt.Text);
                hs.tenQuan   = quanHoSo_Txt.Text;
                hs.dienThoai = long.Parse(dtHoSo_Txt.Text);
                hs.day       = dateHoSo_Txt.Value;
                hs.diaChi    = diaChiHoSo_Txt.Text;
                hs.email     = emailHoSo_Txt.Text;

                bool kq = hsBus.them(hs);
                if (kq == false)
                {
                    MessageBox.Show("Thêm hồ sơ thất bại");
                }
                else
                {
                    MessageBox.Show("Thêm hồ sơ thành công");
                }
            }

            if (function.Text == "Xóa")
            {
                HoSoDTO hs = new HoSoDTO();
                hs.ma = int.Parse(maHoSo_Txt.Text);
                bool kq = hsBus.xoa(hs);
                if (kq == false)
                {
                    MessageBox.Show("Xóa sơ thất bại");
                }
                else
                {
                    MessageBox.Show("Xóa sơ thành công");
                }
            }

            if (function.Text == "Tìm")
            {
                //Check for valid text
                HoSoDTO hs = new HoSoDTO();
                if (maHoSo_Txt.Text.Trim().Length > 0)
                {
                    hs.ma = int.Parse(maHoSo_Txt.Text);
                }
                hs.tenHoSo = tenHoSo_Txt.Text;
                hs.tenQuan = quanHoSo_Txt.Text;
                if (dtHoSo_Txt.Text.Trim().Length > 0)
                {
                    hs.dienThoai = long.Parse(dtHoSo_Txt.Text);
                }
                if (loaiHoSo_Txt.Text.Trim().Length > 0)
                {
                    hs.loai = int.Parse(loaiHoSo_Txt.Text);
                }
                hs.email            = emailHoSo_Txt.Text;
                hs.diaChi           = diaChiHoSo_Txt.Text;
                HoSoGrid.DataSource = hsBus.search(hs, ngay);
            }

            if (function.Text == "Sửa")
            {
                HoSoDTO hs = new HoSoDTO();
                hs.ma        = int.Parse(maHoSo_Txt.Text);
                hs.tenHoSo   = tenHoSo_Txt.Text;
                hs.loai      = int.Parse(loaiHoSo_Txt.Text);
                hs.tenQuan   = quanHoSo_Txt.Text;
                hs.dienThoai = long.Parse(dtHoSo_Txt.Text);
                hs.day       = dateHoSo_Txt.Value;
                hs.diaChi    = diaChiHoSo_Txt.Text;
                hs.email     = emailHoSo_Txt.Text;

                bool kq = hsBus.sua(hs);
                if (kq == false)
                {
                    MessageBox.Show("Sửa hồ sơ thất bại");
                }
                else
                {
                    MessageBox.Show("Sửa hồ sơ thành công");
                }
            }
            if (function.Text != "Tìm")
            {
                HoSoGrid.DataSource = hsBus.Load();
            }
            ClearAll();
            SetReadOnly();
            function.Text = string.Empty;
        }