/// <summary> /// 点击加载数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Click(object sender, EventArgs e) { Ticket model = TicketDAL.FindModel(new Ticket(Convert.ToInt32(textBox3.Text)), "id"); if (model != null) { textBox6.Text = model.movieName; textBox7.Text = model.date; textBox5.Text = model.price; } }
/// <summary> /// 点击删除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button4_Click(object sender, EventArgs e) { if (textBox8.Text == "") { MessageBox.Show("ID不可为空"); return; } Ticket model = new Ticket(); model.Id = Convert.ToInt32(textBox8.Text); if (TicketDAL.FindModel(new Ticket(model.Id), "id") == null) { MessageBox.Show("不存在此ID"); return; } if (TicketDAL.Drop(model, "id")) { FillDataGirdView(); MessageBox.Show("删除成功"); return; } }
/// <summary> /// 点击修改按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button3_Click(object sender, EventArgs e) { if (textBox3.Text == "") { MessageBox.Show("ID不可为空"); return; } Ticket model = new Ticket(); model.Id = Convert.ToInt32(textBox3.Text); model.movieName = textBox6.Text; model.date = textBox7.Text; model.price = textBox5.Text; if (TicketDAL.FindModel(new Ticket(model.Id), "id") == null) { MessageBox.Show("不存在此ID"); return; } if (TicketDAL.AlterByPK(model, "id")) { FillDataGirdView(); MessageBox.Show("修改成功"); return; } }