Exemplo n.º 1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Borrower b = new Borrower();
     b.BorrowerNumber = int.Parse(tbBorrowerNum.Text);
     b.Name = tbName.Text;
     b.Sex = DropDownList1.Text;
     b.Address = tbAddress.Text;
     b.Telephone = tbTelephone.Text;
     b.Email = tbEmail.Text;
     if (BorrowerBL.Insert(b))
     {
         Response.Redirect("Member.aspx");
     }
 }
Exemplo n.º 2
0
        public static Boolean Delete(Borrower b)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString2"].ConnectionString;
                SqlConnection conn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("delete Borrower where borrowerNumber=@borrowerNumber", conn);

                cmd.Parameters.Add(new SqlParameter("@borrowerNumber", b.BorrowerNumber));

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Exemplo n.º 3
0
 public static Borrower gerBorrower(int borrowerNumber)
 {
     try
     {
         string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString2"].ConnectionString;
         SqlConnection cn = new SqlConnection(strConn);
         SqlCommand cmd = new SqlCommand("select * from Borrower where borrowerNumber = @borrowerNumber", cn);
         cmd.Parameters.AddWithValue("@borrowerNumber", borrowerNumber);
         cn.Open();
         SqlDataReader rd = cmd.ExecuteReader();
         if (rd.Read())
         {
             Borrower b = new Borrower(int.Parse(rd["borrowerNumber"].ToString()), rd["name"].ToString(), rd["sex"].ToString(), rd["address"].ToString(), rd["telephone"].ToString(), rd["email"].ToString());
             return b;
         }
         else return null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return null;
     }
 }
Exemplo n.º 4
0
 public static bool Insert(Borrower b)
 {
     return BorrowerDA.Insert(b);
 }
Exemplo n.º 5
0
 public static bool Delete(Borrower b)
 {
     return BorrowerDA.Delete(b);
 }
Exemplo n.º 6
0
 public static bool Update(Borrower b)
 {
     return BorrowerDA.Update(b);
 }
Exemplo n.º 7
0
        public static bool Update(Borrower b)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString2"].ConnectionString;
                SqlConnection conn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Update Borrower set name = @name ,"
                 + "sex = @sex ,address = @address, telephone = @telephone, email = @email where borrowerNumber = @borrowerNumber", conn);

                cmd.Parameters.Add(new SqlParameter("@BorrowerNumber", b.BorrowerNumber));
                cmd.Parameters.Add(new SqlParameter("@name", b.Name));
                cmd.Parameters.Add(new SqlParameter("@sex", b.Sex));
                cmd.Parameters.Add(new SqlParameter("@Address", b.Address));
                cmd.Parameters.Add(new SqlParameter("@Telephone", b.Telephone));
                cmd.Parameters.Add(new SqlParameter("@Email", b.Email));

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Exemplo n.º 8
0
        public static bool Insert(Borrower b)
        {
            try
            {
                string strConn = ConfigurationManager.ConnectionStrings["LibraryConnectionString2"].ConnectionString;
                SqlConnection conn = new SqlConnection(strConn);
                SqlCommand cmd = new SqlCommand("Insert into Borrower(borrowerNumber, name,sex,address, telephone, email) " +
                 "values(@borrowerNumber, @name, @sex, @address,@telephone,@email)", conn);

                cmd.Parameters.Add(new SqlParameter("@BorrowerNumber", b.BorrowerNumber));
                cmd.Parameters.Add(new SqlParameter("@name", b.Name));
                cmd.Parameters.Add(new SqlParameter("@sex", b.Sex));
                cmd.Parameters.Add(new SqlParameter("@Address", b.Address));
                cmd.Parameters.Add(new SqlParameter("@Telephone", b.Telephone));
                cmd.Parameters.Add(new SqlParameter("@Email", b.Email));

                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }