zoukankan      html  css  js  c++  java
  • C/S此次项目中的一些总结

    说实话以前没做过C/S方面的项目 ,只是做ASP.NET WEB方面的工作,虽然 说C/S在学校学过一点,但只是皮毛。

    比如网上常见的登录窗体到主窗体关闭登录窗体 ,

    窗体传值 

    刷新父窗体

    ....

    总结如下:

    1、登录到主窗体 并关闭登录 窗体 

    在programm.cs修改代码:

     static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                FrmLogin fl = new FrmLogin();
                if (fl.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new FrmMain());
                }
               
            }
        }

    登录事件代码:

     WFT.BLL.Login wbl=new WFT.BLL .Login ();
                WFT.Model.Login checkModel = GetModel();
                if (string.IsNullOrEmpty(checkModel.LoginName))
                {
                    MessageBox.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ctxtLoginName.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(checkModel.LoginPass))
                {
                    MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.ctxtLoginPass.Focus();
                    return;
                }
                SqlDataReader loginReader = wbl.denglu(GetModel ());
                if (loginReader.Read())
                {
                    _loginid = int.Parse(loginReader["LoginID"].ToString());
                    MessageBox.Show("登录成功!", "欢迎", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("登录出错,请检查您的账号和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                loginReader.Close();
                loginReader.Dispose();

    2、窗体传值 :

    2.1我用的方法开始比较笨,在A窗体定义变量 

    private int id;

    public int ID

    get { return id;}

    set{ id=value;}

    在事件里对id赋值 比如id=1;

    那么在另一个窗体B里引用ID这个值就行了。

    A aa=new A();

    aa.ID就这样调用id的值了。

    以上是我写的一种方法 。

    2.2以面介绍我的第二种方法 

    private int id;

    public int ID

    get { return id;}

    set{ id=value;}这些写在model层里 用动软生成器生的DAL层里GetModel(int id)方法 

    所以要想调用窗体的值 我们首先要获得id值 ,至于获得id的方法 和2.1的一样。

    在经调用值的窗体里写:

    txtUsername.text=bll.GetModel(id).loginname.trim();

    3、刷新父窗体数据 

    这个问题困扰了我好久 时间 ,把方法整理如下:

    在调用子窗体的地方这么写:

     MessageBox.Show("登录成功!", "欢迎", MessageBoxButtons.OK, MessageBoxIcon.Information);
    //以下是刷新主数据的前提
    this.DialogResult = DialogResult.OK; this.Close();

    在需要刷新主窗体数据的地方(在这里我是用修改的事件)

    代码:

                        Model .Login model=new Model.Login ();
                        model .LoginName =txtLoginName .Text.Trim();
                        model .LoginPass =txtLoginPass.Text.Trim();
                        model.LoginID = fmain.LoginID;
                        wbl.Update(model);
    //以上是调用BLL的更新方法 MessageBox.Show("更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    //开始刷新主窗体数据 FrmMain fmm= (FrmMain )this.Owner ; fmm.BindListLogin(); this.Close();

     4、有很多功能完全用SQL复杂查询来完成 这方面有所欠缺,需要加强。

    在接下来的项目 中我会继续整理这方面的资料 供自己以后学习。

    http://www.hnhqwl.com

  • 相关阅读:
    Redis 查看、删除keys
    gitlab 备份和恢复
    gitlab的搭建
    certbot 域名续期及证书查看
    晴天(周杰伦)
    SSH Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
    jenkins miaration section 1
    jenkins 忘记管理员密码
    Yangk's-树状数组 模板
    codeforces-977F-Consecutive Subsequence【动态规划】
  • 原文地址:https://www.cnblogs.com/nianyuwen/p/2517557.html
Copyright © 2011-2022 走看看