Esempio n. 1
0
        private void btgiahan_Click(object sender, EventArgs e)
        {
            laydulieu dl = new laydulieu();
            DataSet   d  = dl.getdata("select * from phieumuon where maphieumuon='" + maphieumuon + "' and GETdate()- phieumuon.ngaymuon > day(7)");

            if (d.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("Sách này đã quá hạn không thể thực hiện thao tác xin gia hạn được");
            }
            else
            {
                if (txtngaymuon.Text != "")
                {
                    Lphieumuon pm = new Lphieumuon();
                    pm.set_maphieumuon(maphieumuon);
                    pm.set_ngaymuon(DateTime.Parse(DateTime.Now.ToShortDateString()));
                    if (pm.giahan())
                    {
                        bthuythaotac_Click(sender, e);
                        btgiahan.Enabled    = false;
                        btkiemtratt.Enabled = true;
                        MessageBox.Show("Bạn đã thực hiện thành công thao tác");
                    }
                    else
                    {
                        MessageBox.Show("Thao tác gặp lỗi");
                    }
                }
                else
                {
                    MessageBox.Show("Bạn phải kiểm tra thông tin trước khi thực hiện thao tác này");
                }
            }
        }
Esempio n. 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (ktbandoc && ktsach)
            {
                laydulieu     dl  = new laydulieu();
                SqlDataReader dr  = dl.lay_reader("select maphieumuon from phieumuon");
                string        tam = "";
                while (dr.Read())
                {
                    tam = dr[0].ToString();
                }
                L_Ketnoi.HuyKetNoi();
                if (tam == "")
                {
                    tam = "PM00000";
                }
                else
                {
                    tam = maphieumuon(tam);
                }
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("Bạn phải chọn thể thức mượn");
                }
                else
                {
                    if ((comboBox1.Text == strthethuc) && (comboBox1.Text != "Mượn giáo trình"))
                    {
                        MessageBox.Show("Không thể " + strthethuc + " 2 quyển sách, phải trả sách mới được mượn tiếp");
                    }
                    else
                    {
                        if (int.Parse(txtsoluong.Text) < int.Parse(textBox1.Text))
                        {
                            MessageBox.Show("Số lượng sách trong thư viện không đủ cho bạn mượn hãy nhập lại", "Thông báo");
                        }
                        else
                        {
                            if (txtthethuc.Text != comboBox1.Text)
                            {
                                MessageBox.Show("Thể thức bạn mượn sách này không thể đáp ứng được hãy chọn lại sách khác", "Thông báo");
                            }
                            else
                            {
                                Lsach s = new Lsach();
                                s.set_masach(txtmasach.Text);

                                if (s.chomuon(textBox1.Text))
                                {
                                    try
                                    {
                                        int        tamsl = int.Parse(textBox1.Text);
                                        Lphieumuon pm    = new Lphieumuon(tam, txtmabandoc.Text, comboBox1.Text, txtmasach.Text, KTdangnhap.strmanhanvien, DateTime.Parse(DateTime.Now.ToShortDateString()), tamsl);
                                        if (pm.taomoi())
                                        {
                                            Lsachmuon sm = new Lsachmuon(tam);
                                            if (sm.taomoi())
                                            {
                                                button2_Click(sender, e);
                                                MessageBox.Show("Đã hoàn thành thao tác", "Thông báo");
                                            }
                                            else
                                            {
                                                button2_Click(sender, e);
                                                MessageBox.Show("Thao tác gặp lỗi hãy thực hiện lại sau", "Thông báo");
                                            }
                                        }
                                        else
                                        {
                                            button2_Click(sender, e);
                                            MessageBox.Show("Thao tác gặp lỗi hãy thực hiện lại sau", "Thông báo");
                                        }
                                    }
                                    catch { MessageBox.Show(" Nhập sai số lượng sách mượn"); }
                                }
                                else
                                {
                                    MessageBox.Show("Quá trình cho mượn sách bị thất bại");
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Bạn phải kiểm tra thông tin trước mới thực hiện được thao tác này", "Thông báo");
            }
        }