博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2017-5-7 账号激活 权限设置 销售 仓库 财务三大模块
阅读量:6268 次
发布时间:2019-06-22

本文共 8316 字,大约阅读时间需要 27 分钟。

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using 权限设置__销售__仓库__财务三大模块.App_code;namespace 权限设置__销售__仓库__财务三大模块{    public partial class Form1 : Form    {        Form2 F2 = null;        public Form1(users1 u,Form2 f2)        {            InitializeComponent();            F2 = f2;            if(!u.Has.Contains("0"))            {                销售ToolStripMenuItem.Visible = false;            }            if(!u.Has.Contains("1"))            {                仓库ToolStripMenuItem.Visible = false;            }            if(!u.Has.Contains("2"))            {                财务ToolStripMenuItem.Visible = false;            }            F5();        }        public void F5()         {            listView1.Items.Clear();            List
ulist = new users1data().select(); foreach(users1 u in ulist) { ListViewItem li = new ListViewItem(); li.Text = u.Ids.ToString(); li.SubItems.Add(u.Username); li.SubItems.Add(u.Password); li.SubItems.Add(u.State.ToString()); li.SubItems.Add(u.Has); listView1.Items.Add(li); } } private void Form1_Load(object sender, EventArgs e) { } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { F2.Close(); } private void 权限设置ToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 1 || listView1.SelectedItems.Count < 1) { } else { users1 u = new users1data().select(listView1.SelectedItems[0].Text); Form3 f3 = new Form3(u,this); f3.Show(); } } }}

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using 权限设置__销售__仓库__财务三大模块.App_code;namespace 权限设置__销售__仓库__财务三大模块{    public partial class Form2 : Form    {        public Form2()        {            InitializeComponent();        }        private void textBox1_TextChanged(object sender, EventArgs e)        {        }        private void button1_Click(object sender, EventArgs e)        {          users1 u=new users1data().select(textBox1.Text,textBox2.Text);          if (u == null)          {              MessageBox.Show("用户名或密码错误!");          }          else           {              if (u.State)              {                  Form1 f1 = new Form1(u,this);                  f1.Show();              }              else               {                  MessageBox.Show("账号未激活!");              }          }        }    }}

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using 权限设置__销售__仓库__财务三大模块.App_code;namespace 权限设置__销售__仓库__财务三大模块{    public partial class Form3 : Form    {        Form1 F1 = null;        public Form3(users1 u,Form1 f1)        {            InitializeComponent();            F1 = f1;            label1.Text = u.Username;            checkBox1.Checked = u.State;            checkBox2.Checked = u.Has.Contains("0");            checkBox3.Checked = u.Has.Contains("1");            checkBox4.Checked = u.Has.Contains("2");        }        private void button1_Click(object sender, EventArgs e)        {            users1 u = new users1();            u.Username = label1.Text;            u.State = checkBox1.Checked;            string s = "";            if(checkBox2.Checked)            {                s += "0,";            }            if(checkBox3.Checked)            {                s += "1,";            }            if(checkBox4.Checked)            {                s += "2,";            }            u.Has = s;            new users1data().update(u);            MessageBox.Show("修改成功");            F1.F5();            this.Close();        }    }}

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 权限设置__销售__仓库__财务三大模块.App_code{   public class users1    {        private int _ids;        public int Ids        {            get { return _ids; }            set { _ids = value; }        }        private string _username;        public string Username        {            get { return _username; }            set { _username = value; }        }        private string _password;        public string Password        {            get { return _password; }            set { _password = value; }        }        private bool _state;        public bool State        {            get { return _state; }            set { _state = value; }        }        private string _has;        public string Has        {            get { return _has; }            set { _has = value; }        }    }}
using System;using System.Collections.Generic;using System.Data.SqlClient;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 权限设置__销售__仓库__财务三大模块.App_code{    public class users1data    {        SqlConnection conn=null;        SqlCommand cmd=null;        public users1data()        {            conn = new SqlConnection("server=.;database=master;user=sa;pwd=123");            cmd = conn.CreateCommand();        }        public users1 select(string uname,string pwd)         {            users1 u = null;            cmd.CommandText = "select * from users1 where username=@a and password=@b";            cmd.Parameters.Clear();            cmd.Parameters.AddWithValue("@a",uname);            cmd.Parameters.AddWithValue("@b",pwd);            conn.Open();            SqlDataReader dr = cmd.ExecuteReader();            if(dr.HasRows)            {                u = new users1();                dr.Read();                u.Ids = Convert.ToInt32(dr[0]);                u.Username = dr[1].ToString();                u.Password = dr[2].ToString();                u.State = Convert.ToBoolean(dr[3]);                u.Has = dr[4].ToString();            }            conn.Close();            return u;        }        public List
select() { List
ulist = new List
(); cmd.CommandText = "select * from users1"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while(dr.Read()) { users1 u = new users1(); u.Ids = Convert.ToInt32(dr[0]); u.Username = dr[1].ToString(); u.Password = dr[2].ToString(); u.State = Convert.ToBoolean(dr[3]); u.Has = dr[4].ToString(); ulist.Add(u); } } conn.Close(); return ulist; } public void update(users1 u) { cmd.CommandText = "update users1 set state=@a,has=@b where username=@c"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@a",u.State); cmd.Parameters.AddWithValue("@b",u.Has); cmd.Parameters.AddWithValue("@c",u.Username); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } public users1 select(string ids) { users1 u = null; cmd.CommandText = "select * from users1 where ids=@a"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@a", ids); conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { u = new users1(); dr.Read(); u.Ids = Convert.ToInt32(dr[0]); u.Username = dr[1].ToString(); u.Password = dr[2].ToString(); u.State = Convert.ToBoolean(dr[3]); u.Has = dr[4].ToString(); } conn.Close(); return u; } }}

 

转载于:https://www.cnblogs.com/zhengqian/p/6821982.html

你可能感兴趣的文章
Kali Linux 2017中Scapy运行bug解决
查看>>
Python监控进程性能数据并画图保存为PDF文档
查看>>
Android属性动画完全解析(下),Interpolator和ViewPropertyAnimator的用法
查看>>
Mac OS 10.10.3下Apache + mod_wsgi配置【一】
查看>>
Hibernate基于注解的双向one-to-many映射关系的实现
查看>>
算法竞赛入门经典 例题 3-2 蛇形填数
查看>>
remove-duplicates-from-sorted-list I&II——去除链表中重复项
查看>>
c++ 网络库
查看>>
Linux 格式化扩展分区(Extended)
查看>>
linux echo命令
查看>>
nginx 内置变量大全(转)
查看>>
lakala反欺诈建模实际应用代码GBDT监督学习
查看>>
java 解析excel工具类
查看>>
Google FireBase - fcm 推送 (Cloud Messaging)
查看>>
BBS论坛(二十七)
查看>>
html DOM 的继承关系
查看>>
装饰器的邪门歪道
查看>>
Dubbo常用配置解析
查看>>
【转】C#解析Json Newtonsoft.Json
查看>>
macports的安装及常用命令
查看>>