利用C#开发科技档案管理系统(三)
2009-02-27 08:18:17 来源:WEB开发网(7)取消操作
private void tlBtnCancel_Click(object sender, EventArgs e)
{
this.BtnEnabledTrue(); //屏蔽控件-- True
this.BackColorSet_1(); //背景颜色设定
if (G_Int_AddOrUpdate == 0) //添加数据-- 文本清空
{
this.ClearText();
}
}
(8)保存数据操作
private void tlBtnSave_Click(object sender, EventArgs e)
{
if (G_Int_AddOrUpdate == 0) //判断-- 添加数据
{
try
{
if (MySQL.Find_Srl_1_YN(TxtScl_1.Text.ToUpper())) //返回值为True 分类卷号数据已经存在
{
MessageBox.Show("【" + TxtScl_1.Text.ToUpper() + "】分类卷号已经存在,不能重复添加!", "提示...", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
//执行添加
if (TxtScl_1.Text.Trim() == string.Empty) //分类卷号为空时,不能添加数据
{
MessageBox.Show("【分类卷号】为空,不能添加数据!", "提示...", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
//ID号自动设置-- 借助tb_DefaultNO 表
DataSet ds = MySQL.GetDataSetDefaultNO();
string TmpFirstNO2 = ds.Tables[0].Rows[0]["FirstNO2"].ToString();
int TmpCurrentNO2 = Convert.ToInt32(ds.Tables[0].Rows[0]["CurrentNO2"].ToString());
TxtId.Text = TmpFirstNO2.ToString() + (TmpCurrentNO2 + 1).ToString();
int i = MySQL.UpdateCurrentNO2(TmpFirstNO2.ToString(), Convert.ToInt32(TmpCurrentNO2) + 1); //序号增加
//添加数据-- 获取输入值
MyScroll.MyId = TxtId.Text;
MyScroll.MyScl_1 = TxtScl_1.Text.ToUpper(); //转化为大写
MyScroll.MyScl_2 = TxtScl_2.Text.ToUpper(); //转化为大写
MyScroll.MyScl_3 = TxtScl_3.Text;
MyScroll.MyScl_4 = CmbScl_4.Text;
MyScroll.MyScl_5 = TxtScl_5.Text;
MyScroll.MyScl_6 = TxtScl_6.Text;
MyScroll.MyScl_7 = "否(N)"; // CmbScl_7.Text;
MyScroll.MyScl_8 = CmbScl_8.Text;
MyScroll.MyScl_9 = CmbScl_9.Text;
MyScroll.MyScl_10 = CmbScl_10.Text;
MyScroll.MyScl_11 = CmbScl_11.Text;
MyScroll.MyScl_12 = CmbScl_12.Text;
MyScroll.MyScl_13 = CmbScl_13.Text;
MyScroll.MyScl_14 = CmbScl_14.Text;
MyScroll.MyScl_15 = CmbScl_15.Text;
MyScroll.MyScl_16 = CmbScl_16.Text;
MyScroll.MyCreator = BaseClass.ClsComm.Str_UserName.Trim(); //用户名
MyScroll.MyCtime = DateTime.Now.ToString(); //创建时间
int Id = MySQL.Add_Scroll_Data_5(MyScroll);
MessageBox.Show("新增--整本图信息--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.BtnEnabledTrue(); //屏蔽控件-- True
this.BackColorSet_1(); //背景颜色设定
dgvStockList.DataSource = MySQL.GetAll_Scroll_Data_Desc_5("tb_Scroll").Tables[0].DefaultView; //表格赋值-- 刷新
this.SetdgvStockListHeadText(); //表头标题处理.注意:先表格赋值
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误提示...", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
//修改数据-- 获取输入值
MyScroll.MyId = TxtId.Text;
MyScroll.MyScl_1 = TxtScl_1.Text.ToUpper(); //转化为大写
MyScroll.MyScl_2 = TxtScl_2.Text.ToUpper(); //转化为大写
MyScroll.MyScl_3 = TxtScl_3.Text;
MyScroll.MyScl_4 = CmbScl_4.Text;
MyScroll.MyScl_5 = TxtScl_5.Text;
MyScroll.MyScl_6 = TxtScl_6.Text;
MyScroll.MyScl_7 = CmbScl_7.Text;
MyScroll.MyScl_8 = CmbScl_8.Text;
MyScroll.MyScl_9 = CmbScl_9.Text;
MyScroll.MyScl_10 = CmbScl_10.Text;
MyScroll.MyScl_11 = CmbScl_11.Text;
MyScroll.MyScl_12 = CmbScl_12.Text;
MyScroll.MyScl_13 = CmbScl_13.Text;
MyScroll.MyScl_14 = CmbScl_14.Text;
MyScroll.MyScl_15 = CmbScl_15.Text;
MyScroll.MyScl_16 = CmbScl_16.Text;
MyScroll.MyMender = BaseClass.ClsComm.Str_UserName.Trim(); //用户名
MyScroll.MyMtime = DateTime.Now.ToString(); //修改时间
//注意:保存数据时,不进行图号唯一性检查
int Id = MySQL.Update_Scroll_Data_5(MyScroll); //执行修改
MessageBox.Show("修改--整本图信息--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.BtnEnabledTrue(); //屏蔽控件-- True
this.BackColorSet_1(); //背景颜色设定
}
}
更多精彩
赞助商链接