Esempio n. 1
0
        public void Insert(Borrowing borrowing)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@from", borrowing.borrowing_from);
                command.Parameters.AddWithValue("@to", borrowing.borrowing_to);
                command.Parameters.AddWithValue("@isRet", borrowing.borrowing_is_returned);
                command.Parameters.AddWithValue("@clientId", borrowing.client_id);
                command.Parameters.AddWithValue("@copyId", borrowing.copy_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
Esempio n. 2
0
        protected void Button9_Click(object sender, EventArgs e)
        {
            //prida do Borrowing
            DatabaseLibrary.Borrowing bor = new DatabaseLibrary.Borrowing();

            string borrowing_from = TextBox_borrowing_from.Text;
            string[] items = borrowing_from.Split('/');
            DateTime borrowing_from_toDB = new DateTime(Int32.Parse(items[2]), Int32.Parse(items[1]), Int32.Parse(items[0]));

            string borrowing_to = TextBox_borrowing_to.Text;
            string[] items2 = borrowing_to.Split('/');
            DateTime borrowing_to_toDB = new DateTime(Int32.Parse(items2[2]), Int32.Parse(items2[1]), Int32.Parse(items2[0]));

            bor.borrowing_from = borrowing_from_toDB;
            bor.borrowing_to = borrowing_to_toDB;
            bor.borrowing_is_returned = Convert.ToBoolean(TextBox_borrowing_is_returned.Text);
            bor.client_id = Convert.ToInt32(DropDownList_borrowing_client_id.SelectedValue);
            bor.copy_id = Convert.ToInt32(DropDownList_borrowing_copy_id.SelectedValue);

            new DatabaseLibrary.BorrowingTable().Insert(bor);

            Response.Redirect(Request.RawUrl);
        }
Esempio n. 3
0
 private Borrowing ReadBorrowingData(MySqlDataReader reader)
 {
     Borrowing b = new Borrowing();
     b.borrowing_id = reader.GetInt32(0);
     b.borrowing_from = reader.GetDateTime(1);
     b.borrowing_to = reader.GetDateTime(2);
     b.borrowing_is_returned = reader.GetBoolean(3);
     b.client_id = reader.GetInt32(4);
     b.copy_id = reader.GetInt32(5);
     return b;
 }
Esempio n. 4
0
        public Borrowing SelectOne(int borrowingId)
        {
            Borrowing b = new Borrowing();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ONE, conn);
                command.Parameters.AddWithValue("@id", borrowingId);

                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    b = ReadBorrowingData(reader);
                }
                reader.Close();
            }
            return b;
        }