Beispiel #1
0
        public static EBorrowedBooks GetIdOnly(int borrowedBookID)
        {
            SqlCommand cmd = new SqlCommand("spBorrowedBooks_GetIdOnly", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@BorrowedBookID", borrowedBookID);
            Baglanti.conn.Open();
            SqlDataReader  dr = cmd.ExecuteReader();
            EBorrowedBooks b  = new EBorrowedBooks();

            while (dr.Read())
            {
                b.Employee     = new EEmployees();
                b.Member       = new EMembers();
                b.Book         = new EBooks();
                b.ID           = Convert.ToInt32(dr["ID"]);
                b.Employee.ID  = Convert.ToInt32(dr["EmployeeID"]);
                b.Member.ID    = Convert.ToInt32(dr["MemberID"]);
                b.DateOfBorrow = Convert.ToDateTime(dr["DateOfBorrow"]);
                b.ExpireDate   = Convert.ToDateTime(dr["ExpireDate"]);
                b.Book.ID      = Convert.ToInt32(dr["BookID"]);
            }
            dr.Close();
            Baglanti.conn.Close();
            return(b);
        }
        private void btnTeslimAl_Click(object sender, EventArgs e)
        {
            EBorrowedBooks returnBook = new EBorrowedBooks();

            returnBook = (EBorrowedBooks)dataGridView1.SelectedRows[0].DataBoundItem;
            DialogResult result = MessageBox.Show("'" + returnBook.bookName + "'" + " " + "isimli kitabı teslim almak istediğinizden emin misiniz?", "Uyarı", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                returnBook.IsReturned   = false;
                returnBook.DateOfReturn = DateTime.Now;
                bool sonuc = BLLBorrowedBooks.Update(returnBook);
                if (sonuc)
                {
                    MessageBox.Show("Harika! Kitap Teslim Alındı!");
                    txtIsbnNo.Clear();
                }
                else
                {
                    MessageBox.Show("Bir hata oluştu!");
                }
            }

            List <EBorrowedBooks> kiralist = BLLBorrowedBooks.GetAll();

            kiralist = (from k in kiralist
                        where k.IsReturned == true
                        select k).ToList <EBorrowedBooks>();
            dataGridView1.DataSource = kiralist;
        }
 public static bool InsertBorrowedBook(EBorrowedBooks borrowedBook)
 {
     if (borrowedBook.Book.ID < 1 || borrowedBook.DateOfBorrow == null || borrowedBook.Employee.ID < 1 || borrowedBook.ExpireDate == null || borrowedBook.Member.ID < 1)
     {
         return(false);
     }
     else
     {
         DALBorrowedBooks.InsertBorrowedBook(borrowedBook);
         return(true);
     }
 }
Beispiel #4
0
        public static void Update(EBorrowedBooks borrowedBook)
        {
            SqlCommand cmd = new SqlCommand("spBorrowedBooks_Update", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@DateOfReturn", borrowedBook.DateOfReturn);
            cmd.Parameters.AddWithValue("@BorrowedBookID", borrowedBook.ID);
            cmd.Parameters.AddWithValue("@IsReturned", borrowedBook.IsReturned);
            cmd.Parameters.AddWithValue("@BookID", borrowedBook.Book.ID);
            Baglanti.conn.Open();
            cmd.ExecuteNonQuery();
            Baglanti.conn.Close();
        }
Beispiel #5
0
        public static void InsertBorrowedBook(EBorrowedBooks borrowedBook)
        {
            SqlCommand cmd = new SqlCommand("spBorrowedBooks_Insert", Baglanti.conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@BookID", borrowedBook.Book.ID);
            cmd.Parameters.AddWithValue("@EmployeeID", borrowedBook.Employee.ID);
            cmd.Parameters.AddWithValue("@MemberID", borrowedBook.Member.ID);
            cmd.Parameters.AddWithValue("@ExpireDate", borrowedBook.ExpireDate);
            cmd.Parameters.AddWithValue("@DateOfBorrow", borrowedBook.DateOfBorrow);

            Baglanti.conn.Open();
            cmd.ExecuteNonQuery();
            Baglanti.conn.Close();
        }
Beispiel #6
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            if (cmbEmployees.SelectedIndex != -1 & cmbMembers.SelectedIndex != -1 & cmbVerilenKitap.SelectedIndex != -1)
            {
                EBorrowedBooks borrowedBook = new EBorrowedBooks();
                borrowedBook.Book         = new EBooks();
                borrowedBook.Member       = new EMembers();
                borrowedBook.Employee     = new EEmployees();
                borrowedBook.Book.ID      = Convert.ToInt32(cmbVerilenKitap.SelectedValue);
                borrowedBook.Employee.ID  = Convert.ToInt32(cmbEmployees.SelectedValue);
                borrowedBook.Member.ID    = Convert.ToInt32(cmbMembers.SelectedValue);
                borrowedBook.DateOfBorrow = DateTime.Now;
                borrowedBook.ExpireDate   = dtpExpireDate.Value;


                if (borrowedBook.DateOfBorrow <= borrowedBook.ExpireDate)
                {
                    if (BLLBorrowedBooks.InsertBorrowedBook(borrowedBook))
                    {
                        MessageBox.Show("Kayıt işleminiz başarıyla gerçekleşmiştir.");
                        List <EBooks> bookList = BLLBooks.GetBookNames();
                        if (bookList != null && bookList.Count > 0)
                        {
                            bookList = (from l in bookList
                                        where l.IsReturned == false
                                        select l).ToList <EBooks>();
                        }
                        cmbVerilenKitap.DataSource = bookList;
                    }
                    else
                    {
                        MessageBox.Show("Hata Oluştu!");
                    }
                }
                else
                {
                    MessageBox.Show("Kitap Teslim Tarihi, alınan tarihten eski olamaz!");
                }

                cmbEmployees.SelectedIndex    = -1;
                cmbMembers.SelectedIndex      = -1;
                cmbVerilenKitap.SelectedIndex = -1;
            }
            else
            {
                MessageBox.Show("Eksik bilgi girdiniz. Lütfen kontrol ediniz!");
            }
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            if (Request.QueryString["ID"] != null)
            {
                EBorrowedBooks returnBook = new EBorrowedBooks();
                returnBook.ID           = int.Parse(Request.QueryString["ID"]);
                returnBook              = BLLBorrowedBooks.GetIdOnly(returnBook.ID);
                returnBook.DateOfReturn = DateTime.Now;
                returnBook.IsReturned   = false;


                bool sonuc = BLLBorrowedBooks.Update(returnBook);
                if (sonuc)
                {
                    Response.Write("<script>alert('Harika! Kitap Teslim Alındı!')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Bir hata oluştu!')</script>");
                }
            }

            List <EBorrowedBooks> bookList = BLLBorrowedBooks.GetAll();

            if (bookList != null && bookList.Count > 0)
            {
                bookList = (from l in bookList
                            where l.IsReturned == true
                            select l).ToList <EBorrowedBooks>();
            }
            else
            {
                Response.Write("<script>alert('Teslim alınacak kitap bulunamadı!')</script>");
            }
            rptKitaplar.DataSource = bookList;
            rptKitaplar.DataBind();
        }
Beispiel #8
0
        protected void btnKaydet_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(dtpExpireDate.Text))
            {
                EBorrowedBooks borrowedBook = new EBorrowedBooks();
                borrowedBook.Book         = new EBooks();
                borrowedBook.Member       = new EMembers();
                borrowedBook.Employee     = new EEmployees();
                borrowedBook.Book.ID      = Convert.ToInt32(cmbVerilenKitap.SelectedValue);
                borrowedBook.Employee.ID  = Convert.ToInt32(cmbEmployees.SelectedValue);
                borrowedBook.Member.ID    = Convert.ToInt32(cmbMembers.SelectedValue);
                borrowedBook.DateOfBorrow = DateTime.Now;


                string[] alinacakTarArr = dtpExpireDate.Text.Split(new string[] { "." }, StringSplitOptions.None);
                borrowedBook.ExpireDate = new DateTime(int.Parse(alinacakTarArr[2]), int.Parse(alinacakTarArr[1]), int.Parse(alinacakTarArr[0]));

                if (borrowedBook.ExpireDate > DateTime.Now)
                {
                    if (BLLBorrowedBooks.InsertBorrowedBook(borrowedBook))
                    {
                        Response.Write("<script>alert('Kayıt işleminiz başarıyla gerçekleşmiştir.')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Hata Oluştu!')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Kitap Teslim Tarihi, alınan tarihten eski olamaz!')</script>");
                }
                dtpExpireDate.Text = String.Empty;
                cmbEmployees.ClearSelection();
                cmbMembers.ClearSelection();
                cmbVerilenKitap.ClearSelection();
            }
            else
            {
                Response.Write("<script>alert('Eksik bilgi girdiniz. Lütfen kontrol ediniz!')</script>");
            }
        }
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            EBorrowedBooks borrowedBook = ((List <EBorrowedBooks>)(dataGridView1.DataSource))[e.RowIndex];

            if (borrowedBook.DateOfReturn < borrowedBook.ExpireDate && borrowedBook.DateOfReturn != null)
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Yellow;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            }

            else if (borrowedBook.ExpireDate == DateTime.Now && borrowedBook.DateOfReturn == null)
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Orange;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            }

            else if (borrowedBook.ExpireDate < borrowedBook.DateOfReturn && borrowedBook.DateOfReturn != null)
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Purple;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            }

            else if (borrowedBook.ExpireDate <= DateTime.Now && borrowedBook.DateOfReturn == null)
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            }

            else if (borrowedBook.ExpireDate > DateTime.Now && borrowedBook.DateOfReturn == null)
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Green;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.White;
            }
            else
            {
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
                dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Black;
            }
        }
Beispiel #10
0
        public static List <EBorrowedBooks> GetAll()
        {
            SqlCommand cmd = new SqlCommand("spBorrowedBooks_GetAll", Baglanti.conn);

            Baglanti.conn.Open();
            SqlDataReader         dr     = cmd.ExecuteReader();
            List <EBorrowedBooks> bliste = new List <EBorrowedBooks>();

            while (dr.Read())
            {
                EBorrowedBooks b = new EBorrowedBooks();
                b.Employee          = new EEmployees();
                b.Member            = new EMembers();
                b.Book              = new EBooks();
                b.ID                = Convert.ToInt32(dr["ID"]);
                b.Book.Name         = dr["Name"].ToString();
                b.Employee.ID       = Convert.ToInt32(dr["EmployeeID"]);
                b.Employee.FullName = dr["EmployeeName"].ToString();
                b.Member.ID         = Convert.ToInt32(dr["MemberID"]);
                b.Member.FullName   = dr["MemberName"].ToString();
                b.DateOfBorrow      = Convert.ToDateTime(dr["DateOfBorrow"]);
                b.ExpireDate        = Convert.ToDateTime(dr["ExpireDate"]);
                b.Book.ID           = Convert.ToInt32(dr["BookID"]);
                b.Book.ISBNNO       = dr["ISBN No"].ToString();
                b.IsReturned        = Convert.ToBoolean(dr["IsReturned"]);
                if (dr["DateOfReturn"] == DBNull.Value)
                {
                    b.DateOfReturn = null;
                }
                else
                {
                    b.DateOfReturn = Convert.ToDateTime(dr["DateOfReturn"]);
                }
                bliste.Add(b);
            }
            dr.Close();
            Baglanti.conn.Close();
            return(bliste);
        }
 public static bool Update(EBorrowedBooks borrowedbook)
 {
     DALBorrowedBooks.Update(borrowedbook);
     return(true);
 }