你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:杂志经典 / 专家论坛
利用C#开发科技档案管理系统(十)
 

4)增加数据操作

private void tlBtnAdd_Click(object sender, EventArgs e) 

{

            if (Convert.ToBoolean(BaseClass.ClsComm.Int_AddPower))

            {

                this.ClearText();          //文本清空

                this.BtnEnabledFalse();    //屏蔽控件-- False

                G_Int_AddOrUpdate = 0;     //等于0为添加数据

                this.BackColorSet_2();     //背景颜色设定

                this.TxtScl_1.Focus();     //定位焦点

                this.TxtScl_1.Text = "5C."; // -- 分类卷号前缀符五分室图册--

            }

            else

            {

                MessageBox.Show("对不起,您无权进行【添加数据】操作!", "提示...", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;

            }

}

5)编辑数据操作

private void tlBtnEdit_Click(object sender, EventArgs e) 

{

            if (Convert.ToBoolean(BaseClass.ClsComm.Int_EditPower))

            {

                if (TxtId.Text.Trim() == string.Empty)

                {

                    MessageBox.Show("ID号为空,不能进行数据编辑!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;

                }

                else

                {

                    G_Int_AddOrUpdate = 1;    //等于1为修改数据

                    this.BtnEnabledFalse();   //屏蔽控件-- False

                    this.BackColorSet_2();    //背景颜色设定

                    this.TxtScl_1.Focus();    //定位焦点

                }

            }

            else

            {

                MessageBox.Show("对不起,您无权进行【编辑数据】操作!", "提示...", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;

            }

}

6)删除数据操作

private void tlBtnDelete_Click(object sender, EventArgs e) 

{

            if (Convert.ToBoolean(BaseClass.ClsComm.Int_DelePower))

            {

                if (TxtId.Text.Trim() == string.Empty)

                {

                    MessageBox.Show("ID号为空,删除数据失败!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;

                }

                MyScroll.MyId = TxtId.Text.Trim();  //去空格

                try

                {

                    int Id = MySQL.Delete_Scroll_Data_5(MyScroll);  //执行删除

                    MessageBox.Show("删除--整本图信息登记--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    dgvStockList.DataSource = MySQL.GetAll_Scroll_Data_5("tb_Scroll").Tables[0].DefaultView; //表格赋值-- 刷新

                    this.SetdgvStockListHeadText();    //表头标题处理. 注意:先表格赋值

                    this.ClearText();                  //文本清空

                }

                catch (Exception ex)

                {

                    MessageBox.Show(ex.Message, "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

            }

            else

            {

                MessageBox.Show("对不起,您无权进行【删除数据】操作!", "提示...", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;

            }

}

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)";       

                            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();            //背景颜色设定

            }

}

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089