Beispiel #1
0
        private void btnSVXoa_Click(object sender, EventArgs e)
        {
            string _maphieumuon = "";

            try
            {
                _maphieumuon = txtmaphieu.Text;
                MessageBox.Show(_maphieumuon);
            }
            catch { }
            DialogResult dr = MessageBox.Show(" Bạn có chắc chắn xóa ?", "Xác nhận ", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                string ngaymuon = convertToDateSQL(dtpngaymuon.Value.ToString("dd/MM/yyy"));
                string ngaytra  = convertToDateSQL(dtpngaytra.Value.ToString("dd/MM/yyy"));
                myPM = new Models.phieumuon(txtmaphieu.Text, cbmadocgia.Text, cbbmasach.Text, ngaymuon
                                            , ngaytra, txttinhtrang.Text);
                var i = myPM.Deletephieumuon();
                if (i > 0)
                {
                    MessageBox.Show("Xóa Thành Công !");
                }
                else
                {
                    MessageBox.Show("Xóa Không thành công");
                }
            }
            hienthidanhsach();
        }
Beispiel #2
0
 private void btnSVLuu_Click(object sender, EventArgs e)
 {
     if (btnSVLuu.Tag.ToString() == "Them")
     {
         string ngaymuon = convertToDateSQL(dtpngaymuon.Value.ToString("dd/MM/yyy"));
         string ngaytra  = convertToDateSQL(dtpngaytra.Value.ToString("dd/MM/yyy"));
         myPM = new Models.phieumuon(txtmaphieu.Text, cbmadocgia.Text, cbbmasach.Text, ngaymuon
                                     , ngaytra, txttinhtrang.Text);
         //HienThiDanhSachSV();
         var i = myPM.Insertphieumuon();
         if (i == 0)
         {
             MessageBox.Show("Thêm mới thất bại !");
         }
         else
         {
             MessageBox.Show("Thêm mới thành công !");
             hienthidanhsach();
         }
     }
     if (btnSVLuu.Tag.ToString() == "Sua")
     {
         string ngaymuon = convertToDateSQL(dtpngaymuon.Value.ToString("dd/MM/yyy"));
         string ngaytra  = convertToDateSQL(dtpngaytra.Value.ToString("dd/MM/yyy"));
         myPM = new Models.phieumuon(txtmaphieu.Text, cbmadocgia.Text, cbbmasach.Text, ngaymuon
                                     , ngaytra, txttinhtrang.Text);
         var i = myPM.Updatephieumuon();
         if (i == 0)
         {
             MessageBox.Show("Sửa thất bại !");
         }
         else
         {
             MessageBox.Show("Sửa thành công !");
             hienthidanhsach();
         }
     }
 }