• 2017-5-7 账号激活 权限设置 销售 仓库 财务三大模块


    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<users1> 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<users1> select()
            {
                List<users1> ulist = new List<users1>();
                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;
            }
        }
    }
  • 相关阅读:
    序列化
    python_模块与包
    python_常用内置模块
    python_生成器
    python_文件操作
    你好,mysql
    2017年12月20日 内置对象
    2017年12月17日 ASP.NET 12个表单元素&&简单控件/复合控件
    2017年12月16日 ASP.NET基本用法
    2017年12月14日 LinQ高级查&&Asp.net WebForm Asp.net MVC
  • 原文地址:https://www.cnblogs.com/zhengqian/p/6821982.html
Copyright © 2020-2023  润新知