Пример #1
0
 public void Add(CertificateBLL certificate, List<Int32> listBook)
 {
     CertificateDAL.insert(certificate);
     List<CertificateBLL> certificateList = CertificateDAL.getLastCertificateByReaderId(certificate.Iddocgia);
     if (certificateList != null)
     {
         foreach (Int32 bookId in listBook)
         {
             BookBorrowDAL.Insert(bookId, certificateList[certificateList.Count-1].Idphieumuon);
             BookDAL.changeStatus(bookId);
         }
     }
 }
Пример #2
0
 protected void btnConfirm_Click(object sender, EventArgs e)
 {
     Int64 readerId = Int64.Parse(Session["ReaderId"].ToString());
     DateTime dateAdded = DateTime.Now;
     DateTime dateEnd = dateAdded.AddDays(10);
     List<Int32> bookList = new List<Int32>();
     if (Session["bookId1"] != null)
     {
         if (Session["bookId2"] != null)
         {
             if (Session["bookId3"] != null)
             {
                 bookList.Add(Int32.Parse(Session["bookId1"].ToString()));
                 bookList.Add(Int32.Parse(Session["bookId2"].ToString()));
                 bookList.Add(Int32.Parse(Session["bookId3"].ToString()));
             }
             else
             {
                 bookList.Add(Int32.Parse(Session["bookId1"].ToString()));
                 bookList.Add(Int32.Parse(Session["bookId2"].ToString()));
             }
         }
         else
         {
             bookList.Add(Int32.Parse(Session["bookId1"].ToString()));
         }
     }
     else
     {
         Response.Redirect("Book.aspx");
     }
     CertificateBLL certificateBLL = new CertificateBLL(1, readerId, dateAdded, dateEnd);
     BorrowBookBLL borrowBookBLL = new BorrowBookBLL();
     try
     {
         borrowBookBLL.Add(certificateBLL, bookList);
         string script = "alert(\"Success!\");";
         ScriptManager.RegisterStartupScript(this, GetType(),
                               "ServerControlScript", script, true);
         this.btnConfirm.Visible = false;
         this.btnCancel.Visible = false;
         Session.Abandon();
         //Response.Redirect("Reader.aspx");
     }
     catch (Exception ex)
     {
         string script = "alert(\"Error while add certificate: "+ex.Message+"\");";
         ScriptManager.RegisterStartupScript(this, GetType(),
                               "ServerControlScript", script, true);
     }
 }
Пример #3
0
        public void Add(CertificateBLL certificate, List <Int32> listBook)
        {
            CertificateDAL.insert(certificate);
            List <CertificateBLL> certificateList = CertificateDAL.getLastCertificateByReaderId(certificate.Iddocgia);

            if (certificateList != null)
            {
                foreach (Int32 bookId in listBook)
                {
                    BookBorrowDAL.Insert(bookId, certificateList[certificateList.Count - 1].Idphieumuon);
                    BookDAL.changeStatus(bookId);
                }
            }
        }
Пример #4
0
        public static List<CertificateBLL> getManageCertificateList()
        {
            String sql = "SELECT * FROM [phieumuon] INNER JOIN [tinhtrangphieumuon] ON phieumuon.idtinhtrang = tinhtrangphieumuon.idtinhtrang INNER JOIN [docgia] ON phieumuon.madocgia = docgia.madocgia";
            DataTable dt = CertificateDAL._condb.getDataTable(sql);
            List<CertificateBLL> manageCertificateBLLList = new List<CertificateBLL>();
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    CertificateBLL manageCertificateBLL = new CertificateBLL(Int32.Parse(row["maphieumuon"].ToString()), Int32.Parse(row["idtinhtrang"].ToString()), row["tendocgia"].ToString(), Int64.Parse(row["madocgia"].ToString()),row["tentinhtrang"].ToString(), Boolean.Parse(row["lacbcnv"].ToString()), DateTime.Parse(row["ngaymuon"].ToString()), DateTime.Parse(row["hantra"].ToString()));
                    manageCertificateBLLList.Add(manageCertificateBLL);

                }
                return manageCertificateBLLList;
            }
            else
            {
                return null;
            }
        }
Пример #5
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     string key = this.txtSearch.Text;
     if (key == "".Trim())
     {
         MessageBox.Show("Please enter keyword!", "Notice");
         return;
     }
     string catalog = "";
     //MessageBox.Show(this.cboSearch.SelectedItem.ToString());
     if (this.cboSearch.SelectedItem.ToString() == "Certificate")
     {
         catalog+= "phieumuon.maphieumuon";
         //MessageBox.Show(catalog);
     }
     else if (this.cboSearch.SelectedItem.ToString() == "Certificate Stt")
     {
         catalog+= "tinhtrangphieumuon.tentinhtrang";
         //MessageBox.Show(catalog);
     }
     CertificateBLL bookStatusBLL = new CertificateBLL();
     List<CertificateBLL> certificateStatusArr = new List<CertificateBLL>();
     certificateStatusArr = CertificateDAL.search(key,catalog);
     this.dgvCertificateStt.Rows.Clear();
     if (certificateStatusArr != null)
     {
         //MessageBox.Show("ok");
         foreach (CertificateBLL row in certificateStatusArr)
         {
             this.dgvCertificateStt.Rows.Add(row.Idphieumuon, row.Tentinhtrang, row.Ngaymuon, row.Hantra, row.Tendocgia, row.Lacnvc, row.Iddocgia);
         }
     }
     else
     {
         MessageBox.Show("Sorry! Can't find this certificate");
         return;
     }
     this.GetSelectedValue();
     this.dgvCertificateStt.SelectionChanged += new EventHandler(dgvCertificateStt_SelectionChanged);
 }
Пример #6
0
 private void LoadDataToGridView()
 {
     this.dgvCertificateStt.Rows.Clear();
     CertificateBLL manageCertificateBLL = new CertificateBLL();
     List<CertificateBLL> manageCertificateArr = new List<CertificateBLL>();
     manageCertificateArr = CertificateDAL.getManageCertificateList();
     //MessageBox.Show("ok");
     foreach (CertificateBLL row in manageCertificateArr)
     {
         this.dgvCertificateStt.Rows.Add(row.Idphieumuon, row.Tentinhtrang,row.Ngaymuon, row.Hantra, row.Tendocgia, row.Lacnvc, row.Iddocgia);
     }
     this.GetSelectedValue();
     this.dgvCertificateStt.SelectionChanged += new EventHandler(dgvCertificateStt_SelectionChanged);
 }
Пример #7
0
 public static void insert(CertificateBLL certificateBLL)
 {
     string sql = "INSERT INTO [phieumuon] (idtinhtrang, madocgia, ngaymuon, hantra) VALUES ("+certificateBLL.Idtinhtrang+", "+certificateBLL.Iddocgia+", '"+certificateBLL.Ngaymuon+"', '"+certificateBLL.Hantra+"')";
     CertificateDAL._condb.ExecuteNonQuery(sql);
 }
Пример #8
0
        public static List<CertificateBLL> search(string value, string catalog)
        {
            string sql = "SELECT * FROM [phieumuon] INNER JOIN [tinhtrangphieumuon] ON phieumuon.idtinhtrang = tinhtrangphieumuon.idtinhtrang INNER JOIN [docgia] ON phieumuon.madocgia = docgia.madocgia where "+catalog+" LIKE N'%" +value+"%'";
            DataTable dt = CertificateDAL._condb.getDataTable(sql);
            List<CertificateBLL> certificateStatusBLLList = new List<CertificateBLL>();
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    CertificateBLL certificateStatusBLL = new CertificateBLL(Int32.Parse(row["maphieumuon"].ToString()), Int32.Parse(row["idtinhtrang"].ToString()), row["tendocgia"].ToString(), Int64.Parse(row["madocgia"].ToString()), row["tentinhtrang"].ToString(), Boolean.Parse(row["lacbcnv"].ToString()), DateTime.Parse(row["ngaymuon"].ToString()), DateTime.Parse(row["hantra"].ToString()));
                    certificateStatusBLLList.Add(certificateStatusBLL);

                }
                return certificateStatusBLLList;
            }
            else
            {
                return null;
            }
        }