Пример #1
0
        /// 生成应用程序
        private void GeneralApp()
        {
            DataSet dataSet = CCTDContext.GetMenu(Userinfo.Username);

            if (dataSet.Tables[0].Rows.Count == 0)
            {
                return;
            }

            DataRow dataRow = dataSet.Tables[0].Rows[0];

            TreeNode root = CreateNode(dataRow);

            root.Expand();
            treeView.Nodes.Add(root);
        }
Пример #2
0
        /// 登陆按钮事件
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text.Trim().Length == 0 || txtPassword.Text.Trim().Length == 0)
            {
                MessageBox.Show("用户名称与密码输入不能为空!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (CCTDContext.Login(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
            {
                Userinfo.Username = txtUsername.Text.Trim();
                this.DialogResult = DialogResult.OK;

                using (FileStream fileStream = new FileStream(FilePath, FileMode.Create))
                {
                    try
                    {
                        StreamWriter streamWriter = new StreamWriter(fileStream);
                        streamWriter.WriteLine("<?xml version=\"1.0\" standalone=\"yes\"?>");
                        streamWriter.WriteLine("<Username>{0}</Username>", Userinfo.Username);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }
                    catch
                    { }
                    finally
                    {
                        fileStream.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("用户名称与密码输入不正确!", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (++i == 3)
                {
                    this.DialogResult = DialogResult.Cancel;
                }
            }
        }