예제 #1
0
        private void Part0_Save_Click(object sender, EventArgs e)
        {
            try
            {
                //添加数据
                Ownerinfo.id       = txt0ID.Text;
                Ownerinfo.idcard   = txtIDCard.Text;
                Ownerinfo.sex      = cmbSex.Text;
                Ownerinfo.age      = txtAge.Text;
                Ownerinfo.job      = txtJob.Text;
                Ownerinfo.workUnit = txtWorkUnit.Text;
                Ownerinfo.weight   = txtWeight.Text;



                //执行添加
                int id = MyMC.AddOwner(Ownerinfo);
                MessageBox.Show("新增--基础数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            dataGridView0.DataSource = MyMC.GetAllOwner("Owner").Tables[0].DefaultView;
            this.SetdataGridView0HeadText();
        }
예제 #2
0
        private void tlBtnSave_Click(object sender, EventArgs e)
        {
            //判断是添加还是修改数据
            if (G_Int_addOrUpdate == 0)
            {
                try
                {
                    //添加数据
                    Ownerinfo.id       = txtID.Text;
                    Ownerinfo.idcard   = txtIDCard.Text;
                    Ownerinfo.sex      = cmbSex.Text;
                    Ownerinfo.age      = txtAge.Text;
                    Ownerinfo.job      = txtJob.Text;
                    Ownerinfo.workUnit = txtWorkUnit.Text;
                    Ownerinfo.weight   = txtWeight.Text;

                    //执行添加
                    int id = baseinfo.AddOwner(Ownerinfo);
                    MessageBox.Show("新增--基础数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                //修改数据
                Ownerinfo.id       = txtID.Text;
                Ownerinfo.idcard   = txtIDCard.Text;
                Ownerinfo.sex      = cmbSex.Text;
                Ownerinfo.age      = txtAge.Text;
                Ownerinfo.job      = txtJob.Text;
                Ownerinfo.workUnit = txtWorkUnit.Text;
                Ownerinfo.weight   = txtWeight.Text;

                //执行修改
                int id = baseinfo.UpdateOwner(Ownerinfo);
                MessageBox.Show("修改--基础数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            dgvOwnerList.DataSource = baseinfo.GetAllOwner("Owner").Tables[0].DefaultView;
            this.SetdgvOwnerListHeadText();
            this.cancelEnabled();
        }