コード例 #1
0
ファイル: Form2.cs プロジェクト: qaz734913414/PDF.NET-SOD
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!MyWinForm.ValidateIBControls(Controls))
            {
                //MessageBox.Show("请输入用户名!");
                return;
            }


            var ibCommandList = MyWinForm.Instance.AutoUpdateIBFormData(this.Controls);

            if (dlbUID.Text == "" || dlbUID.Text == "0")
            {
                //====插入数据的模式====
                IBCommand command = ibCommandList[0];
                dlbUID.Text = command.InsertedID.ToString();//为自增数据的控件赋值

                ////收集数据到实体类中
                User user = new User();
                MyWinForm.DataMap.CollectData(user, this.Controls, true);
                //添加实体类到主窗体的网格控件中
                Form1 form1 = this.Owner as Form1;
                form1.AddUserModel(user);
            }
            else
            {
                //====修改数据的模式=====
                Form1 form1 = this.Owner as Form1;
                //找到主窗体中的实体类对象
                User user1 = form1.GetUserByID(int.Parse(dlbUID.Text));
                //收集当前窗体的数据到实体类中,从而同步更新主窗体的数据
                MyWinForm.DataMap.CollectData(user1, this.Controls, true);
            }
            MessageBox.Show("保存成功!");
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.dtbSN.Text = this.ddlManufacturer.SelectedValue;
            //保存数据
            List <IBCommand> ibCommandList = MyWebForm.Instance.AutoUpdateIBFormData(this.Controls);

            //获取插入的ID
            if (dlCHJLH.Text == "")
            {
                if (ibCommandList.Count > 0)
                {
                    IBCommand command = ibCommandList[0];
                    dlCHJLH.Text = command.InsertedID.ToString();
                }
            }//end if
            lblMsg.Text = "保存成功!";
            //重新绑定数据
            this.ProPageToolBar1.ReBindResultData();
        }