示例#1
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            lbPrice.Visible = false;
            if (tbType.Text == "A" || tbType.Text == "R")
            {
                lbType.Visible = false;
                bool test = true;

                double price = 0;
                try
                {
                    price = double.Parse(tbPrice.Text);
                }
                catch (Exception)
                {
                    lbPrice.Visible = true;
                    test = false;
                }

                if (test == true && price >= 0)
                {
                    Copy c = new Copy(int.Parse(tbBookNum.Text), int.Parse(tbCopyNum.Text), int.Parse(tbSequence.Text), char.Parse(tbType.Text), price);
                    CopyBL.Insert(c);
                    Response.Redirect("~/GUI/CopyBookUI.aspx");
                }
                else
                {
                    lbPrice.Visible = true;
                }
            }
            else
            {
                lbType.Visible = true;
            }
        }
示例#2
0
 protected void gvCopyBook_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     GridViewRow row = gvCopyBook.SelectedRow;
     if (row != null)
     {
         string s = gvCopyBook.Rows[e.RowIndex].Cells[1].Text;
         Copy c = new Copy();
         c.CopyNumber = int.Parse(s);
         CopyBL.Delete(c);
         FillCopyBook();
     }
     else
     {
         ClientScript.RegisterClientScriptBlock(this.GetType(), "wtf", "alert('Please select a copy!');", true);
     }
 }
示例#3
0
        public static bool Delete(Copy c)
        {
            try
            {
                string conn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(conn);
                SqlCommand cmd = new SqlCommand("Delete Copy where copyNumber = @copyNumber", cn);
                cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);

                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
示例#4
0
 public static bool Update(Copy c)
 {
     return CopyDA.Update(c);
 }
示例#5
0
 public static bool Insert(Copy c)
 {
     return CopyDA.Insert(c);
 }
示例#6
0
 public static bool Delete(Copy c)
 {
     return CopyDA.Delete(c);
 }
示例#7
0
        public static bool Update(Copy c)
        {
            try
            {
                string conn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(conn);
                SqlCommand cmd = new SqlCommand("Update Copy set sequenceNumber = @sequenceNumber, "
                + "type = @type,bookNumber = @bookNumber,price = @price where copyNumber = @copyNumber", cn);
                cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);
                cmd.Parameters.AddWithValue("@type", c.Type);
                cmd.Parameters.AddWithValue("@price", c.Price);
                cmd.Parameters.AddWithValue("@sequenceNumber", c.SequenceNumber);
                cmd.Parameters.AddWithValue("@bookNumber", c.BookNumber);

                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
示例#8
0
 public static Copy SelectByID(string s)
 {
     try
     {
         string conn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
         string sql = "SELECT * FROM Copy where copyNumber = " + s;
         SqlDataAdapter da = new SqlDataAdapter(sql, conn);
         DataSet ds = new DataSet();
         da.Fill(ds);
         Copy b = new Copy();
         b.CopyNumber = int.Parse(ds.Tables[0].Rows[0][0].ToString());
         b.BookNumber = int.Parse(ds.Tables[0].Rows[0][1].ToString());
         b.SequenceNumber = int.Parse(ds.Tables[0].Rows[0][2].ToString());
         b.Type = char.Parse(ds.Tables[0].Rows[0][3].ToString());
         b.Price = double.Parse(ds.Tables[0].Rows[0][4].ToString());
         return b;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return new Copy();
     }
 }
示例#9
0
        public static bool Insert(Copy c)
        {
            try
            {
                string conn = ConfigurationManager.ConnectionStrings["LibraryConnectionString"].ConnectionString;
                SqlConnection cn = new SqlConnection(conn);
                SqlCommand cmd = new SqlCommand("Insert into Copy(copyNumber, bookNumber, sequenceNumber, type, price) " +
                "values(@copyNumber, @bookNumber, @sequenceNumber, @type, @price)", cn);
                cmd.Parameters.AddWithValue("@copyNumber", c.CopyNumber);
                cmd.Parameters.AddWithValue("@bookNumber", c.BookNumber);
                cmd.Parameters.AddWithValue("@sequenceNumber", c.SequenceNumber);
                cmd.Parameters.AddWithValue("@type", c.Type);
                cmd.Parameters.AddWithValue("@price", c.Price);

                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

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