|
楼主 |
发表于 2013-6-14 16:55:26
|
显示全部楼层
父窗体:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
namespace WinForms
{
public partial class UpdateTruck : Form
{
public UpdateTruck()
{
InitializeComponent();
}
public List<TbTruck> list { get; set; }
/// <summary>
/// 定义属性保存选中的卡车信息
/// </summary>
public TbTruck tbTruck { get; set; }
TbTruck t = new TbTruck();
/// <summary>
/// 更新卡车信息
/// </summary>
public void Update_TruckInfo()
{
t.Id = tbTruck.Id;
t.Chpahaaa = this.txt_chpahaaa.Text.Trim();
t.Chlisuyo = this.txt_chlisuyo.Text.Trim();
t.Jifeduwe = this.txt_jifeauwe.Text.Trim();
t.Chcuaaaa = this.txt_chcuaaaa.Text.Trim();
t.Duweaaaa = this.txt_duweaaaa.Text.Trim();
t.CrtUser = this.txt_crt_user.Text.Trim();
//t.CrtDate = Convert.ToDateTime(this.txt_crt_date.Text.Trim());
t.CrtDate = dtp_truck.Value;
int count = TruckManage.Update(t);
if (count > 0)
{
MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else
{
MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label7_Click(object sender, EventArgs e)
{
}
private void btnSubmit_Click(object sender, EventArgs e)
{
Update_TruckInfo();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void StruckDetail_Load(object sender, EventArgs e)
{
if (!DesignMode)
{
try
{
TbTruck t = TruckManage.SelectOnTruckId(Convert.ToInt32(tbTruck.Id));
this.txt_chpahaaa.Text = t.Chpahaaa;
this.txt_chlisuyo.Text = t.Chlisuyo;
this.txt_jifeauwe.Text = t.Jifeduwe;
this.txt_chcuaaaa.Text = t.Chcuaaaa;
this.txt_duweaaaa.Text = t.Duweaaaa;
this.txt_crt_user.Text = t.CrtUser;
//this.txt_crt_date.Text = t.CrtDate.ToString();
dtp_truck.Value = t.CrtDate;
//UpdateTruck.
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
子窗体:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
namespace WinForms
{
public partial class AddTruck : UpdateTruck
{
public AddTruck()
{
InitializeComponent();
}
TbTruck t = new TbTruck();
/// <summary>
/// 添加卡车信息
/// </summary>
private void Add_TruckInfo()
{
t.Chpahaaa = this.txt_chpahaaa.Text.Trim();
t.Chlisuyo = this.txt_chlisuyo.Text.Trim();
t.Jifeduwe = this.txt_jifeauwe.Text.Trim();
t.Chcuaaaa = this.txt_chcuaaaa.Text.Trim();
t.Duweaaaa = this.txt_duweaaaa.Text.Trim();
t.CrtUser = this.txt_crt_user.Text.Trim();
//t.CrtDate = Convert.ToDateTime(this.txt_crt_date.Text.Trim());
t.CrtDate = Convert.ToDateTime(dtp_truck.Value);
int count = TruckManage.AddTruck(t);
if (count > 0)
{
MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else
{
MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
//protected override void btnSubmit_Click(object sender, EventArgs e)
//{
// Add_TruckInfo();
//}
protected void btnAddSubmit_Click(object sender, EventArgs e)
{
Add_TruckInfo();
}
protected void btnAddCancel_Click(object sender, EventArgs e)
{
this.Close();
}
//protected override void btnCancel_Click(object sender, EventArgs e)
//{
// this.Close();
//}
private void AddTruck_Load(object sender, EventArgs e)
{
}
}
}
做了一点改动 |
|