예제 #1
0
        private void btn_Sua_Click(object sender, EventArgs e)
        {
            if (!checknull())
            {
                return;
            }
            trangThietBi trangThietBi = new trangThietBi();

            trangThietBi.ten               = txt_Ten.Text;
            trangThietBi.ma                = txt_Ma.Text;
            trangThietBi.tinhTrang         = cb_tinhTrang.Text;
            trangThietBi.ngayMua           = dT_ngayMua.Value;
            trangThietBi.giaThanh          = (int)UD_giaThanh.Value;
            trangThietBi.baoHanh           = (int)UD_baoHanh.Value;
            trangThietBi.ngayHetHanBaoHanh = dT_ngayHetHan.Value;
            trangThietBi.hangSanXuat       = txt_hangSX.Text;
            Database.trangThietBi data = new Database.trangThietBi();
            if ("Thêm" == btn_Sua.Text)
            {
                data.insertData(trangThietBi);
                MessageBox.Show("Thiết bị đã đươc thêm!", "Success");
                log.Insert("Thêm thiết bị " + trangThietBi.ten);
            }
            else if ("Sửa" == btn_Sua.Text)
            {
                data.updateData(trangThietBi);
                MessageBox.Show("Thiết bị đã đươc chỉnh sửa!", "Success");
                log.Insert("Chỉnh sửa thông tin thiết bị " + trangThietBi.ten);
            }
            this.Close();
        }
예제 #2
0
        private void LoadData()
        {
            trangThietBi data        = new trangThietBi();
            DataTable    thietbiList = data.getData();

            dtgv_ThietBiList.DataSource = thietbiList;
            SetHeader();
        }
예제 #3
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            dtgv_ThietBiList.DataSource = null;
            trangThietBi trangThietBi = new trangThietBi();
            DataTable    thietbiList  = trangThietBi.searchData(txt_search.Text);

            dtgv_ThietBiList.DataSource = thietbiList;
            SetHeader();
        }
예제 #4
0
 private void txt_search_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         dtgv_ThietBiList.DataSource = null;
         trangThietBi trangThietBi = new trangThietBi();
         DataTable    thietbiList  = trangThietBi.searchData(txt_search.Text);
         dtgv_ThietBiList.DataSource = thietbiList;
         SetHeader();
     }
 }
예제 #5
0
 public ChiTietThietBi(trangThietBi trangThietBi)
 {
     InitializeComponent();
     txt_Ten.Text        = trangThietBi.ten;
     txt_Ma.Text         = trangThietBi.ma;
     cb_tinhTrang.Text   = trangThietBi.tinhTrang;
     dT_ngayMua.Value    = trangThietBi.ngayMua;
     UD_giaThanh.Value   = trangThietBi.giaThanh;
     UD_baoHanh.Value    = trangThietBi.baoHanh;
     dT_ngayHetHan.Value = trangThietBi.ngayHetHanBaoHanh;
     txt_hangSX.Text     = trangThietBi.hangSanXuat;
     txt_Ma.ReadOnly     = true;
     btn_Sua.Text        = "Sửa";
 }
예제 #6
0
        private void xóaThiếtBịToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Xác nhận xóa thiết bị này khỏi danh sách?", "Caution!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Class.trangThietBi thietBi = new Class.trangThietBi();
                int currentRowIndex        = dtgv_ThietBiList.CurrentCellAddress.Y;// 'current row selected
                if (-1 < currentRowIndex && currentRowIndex < dtgv_ThietBiList.RowCount)
                {
                    thietBi.ten       = dtgv_ThietBiList.Rows[currentRowIndex].Cells["ten"].Value.ToString();
                    thietBi.ma        = dtgv_ThietBiList.Rows[currentRowIndex].Cells["ma"].Value.ToString();
                    thietBi.tinhTrang = dtgv_ThietBiList.Rows[currentRowIndex].Cells["tinhTrang"].Value.ToString();
                }
                trangThietBi trangThietBi = new trangThietBi();
                trangThietBi.deleteData(thietBi);
                Log.Insert("Xóa thông tin thiết bị " + thietBi.ten);
                LoadData();
            }
            else if (dialogResult == DialogResult.No)
            {
                //do something else
            }
        }