winform子窗体加载父窗体事件

在调用子窗体的地方写以下代码:

private void c1FlexGrid1_DoubleClick(object sender, EventArgs e)
      {
          C1ID = int.Parse(c1FlexGrid1[c1FlexGrid1.Row, 1].ToString().Trim());
         // MessageBox.Show(Convert.ToString(C1ID));
          FrmUpdateUser fuu = new FrmUpdateUser();
          fuu.Owner = this;
          fuu.ShowDialog();
      }

 在子窗体修改数据后 写以下代码:

复制代码
 private void c1Button1_Click(object sender, EventArgs e)
        {
            if (txtLoginName.Text.Trim() != wbl.GetModel(fmain.LoginID).LoginName.Trim())
            {
                //说明用户名有改动 要检查是否重复!
                if (wbl.Exists(txtLoginName.Text.Trim()))
                {
                    MessageBox.Show("对不起,此用户名已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtLoginName.Focus();
                    return;
                }
                else
                {
                    Model .Login model=new Model.Login ();
                    model .LoginName =txtLoginName .Text.Trim();
                    model .LoginPass =txtLoginPass.Text.Trim();
                    model.LoginID = fmain.LoginID;
                    wbl.Update(model);
                    MessageBox.Show("更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   FrmMain fmm= (FrmMain )this.Owner ;
                   fmm.BindListLogin();
                   this.Close();
                }
            }
        }
展开阅读全文

没有更多推荐了,返回首页