예제 #1
0
        /// <summary>
        /// 修改员工信息
        /// </summary>
        /// <param name="emp">实体</param>
        /// <returns>修改状态</returns>
        public int setEmployeeLevelUpdate(employeeLevel emp)
        {
            string sql = string.Format("update employeeLevel set jobNumber='{0}',userName='******',parent_id={2},stock='{3}',shuxin='{4}',superiorNumber='{5}',subordinateNumber='{6}',merchantNumber='{7}' where id={8}",
                                       emp.JobNumber, emp.UserName, emp.Parent_id, emp.Stock, emp.Shuxin, emp.SuperiorNumber, emp.SubordinateNumber, emp.MerchantNumber, emp.Id);

            return(ple.GetExecuteNonQuery(sql));
        }
예제 #2
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            //定义实体变量
            employeeLevel emp = new employeeLevel();

            //验证后得到数据,
            if (this.vadata(emp) == null)
            {
                return;
            }
            //调用add
            int tt = sql.setEmployeeLeveLAdd(emp);

            if (tt == 1)
            {
                //日志信息
                employeeLevelLog     empLog = new employeeLevelLog();
                List <employeeLevel> st     = sql.getEmployeeLevelParent(emp.Parent_id);
                if (st != null && st.Count != 0)
                {
                    empLog.JobNumber = st[0].JobNumber;
                    empLog.UserName  = st[0].UserName;
                    empLog.Stock     = emp.Stock;
                    this.setLog(empLog);
                }
                //调用函数,加载,刷新
                //调用函数,加载,刷新
                this.dataListView("");
                MessageBox.Show("添加成功!");
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
예제 #3
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="emp">实体</param>
        /// <returns>添加状态</returns>
        public int setEmployeeLeveLAdd(employeeLevel emp)
        {
            string sql = string.Format(" INSERT  INTO `employeeLevel`(`jobNumber`,`userName`,`parent_id`,`stock`,`dateTime`,`shuxin`,`merchantNumber`) " +
                                       "VALUES  ('{0}','{1}',{2},'{3}',DEFAULT,'{4}','{5}')", emp.JobNumber, emp.UserName, emp.Parent_id, emp.Stock, emp.Shuxin, emp.MerchantNumber);

            return(ple.GetExecuteNonQuery(sql));
        }
예제 #4
0
 /// <summary>
 /// 递归,得到员工树
 /// </summary>
 /// <param name="temp">当前节点name</param>
 /// <param name="root">树</param>
 public void getNode(employeeLevel temp, TreeNode root)
 {
     //循环遍历
     if (temp.ChildEmployeeLevel != null)
     {
         foreach (employeeLevel temp1 in temp.ChildEmployeeLevel)
         {
             TreeNode node2 = new TreeNode();
             node2.Text = temp1.UserName + "(" + temp1.SubordinateNumber + ")";
             root.Nodes.Add(node2);
             this.getNode(temp1, node2);
         }
     }
 }
예제 #5
0
        /// <summary>
        /// 修改员工信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            //判断是否选中了
            if (listView1.SelectedItems.Count != 0)
            {
                //定义实体变量
                employeeLevel emp = new employeeLevel();
                emp.SuperiorNumber    = listView1.SelectedItems[0].SubItems[3].Text;
                emp.SubordinateNumber = listView1.SelectedItems[0].SubItems[4].Text;
                emp.MerchantNumber    = listView1.SelectedItems[0].SubItems[5].Text;

                //验证后得到数据,
                if (this.vadata(emp) == null)
                {
                    return;
                }
                //父id
                emp.Parent_id = Int32.Parse(cob_parent_id.Text.Split('.')[0].ToString());
                if (emp.Parent_id == emp.Id)
                {
                    MessageBox.Show("不能选择自己作为父级!"); return;
                }

                DialogResult dr = MessageBox.Show("确定之前请注意防止关系循环!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dr != DialogResult.OK)
                {
                    return;                        //点取消的代码
                }
                //调用Update
                int tt = sql.setEmployeeLevelUpdate(emp);
                if (tt == 1)
                {
                    //调用函数,加载,刷新
                    this.dataListView("");
                    MessageBox.Show("修改成功!");
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
            else
            {
                MessageBox.Show("请选择要修改的员工!");
            }
        }
예제 #6
0
파일: DBHeple.cs 프로젝트: lingfe/ally
        /// <summary>
        /// 定义查询所有员工等级的方法
        /// </summary>
        /// <param name="sql">SQL语句</param>
        /// <returns>List集合,包含employeeLevel数据</returns>
        public List <employeeLevel> getEmployeeLevel(string sql)
        {
            List <employeeLevel> st = new List <employeeLevel>();

            try
            {
                //con.Open();
                cmd = new MySqlCommand(sql, con);
                dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    employeeLevel fo = new employeeLevel();
                    fo.Id                = Convert.ToInt32(dr["id"]);
                    fo.UserName          = dr["userName"].ToString();
                    fo.JobNumber         = dr["jobNumber"].ToString();
                    fo.Parent_id         = Convert.ToInt32(dr["parent_id"]);
                    fo.Stock             = dr["stock"].ToString();
                    fo.DateTime          = DateTime.Parse(dr["dateTime"].ToString());
                    fo.Shuxin            = dr["shuxin"].ToString();
                    fo.SuperiorNumber    = dr["superiorNumber"].ToString();
                    fo.SubordinateNumber = dr["subordinateNumber"].ToString();
                    fo.MerchantNumber    = dr["merchantNumber"].ToString();

                    st.Add(fo);
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                Console.WriteLine(ex.Message);
            }
            finally
            {
                //con.Close();
            }

            return(st);
        }
예제 #7
0
 /// <summary>
 /// 删除员工信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click_1(object sender, EventArgs e)
 {
     //判断是否选中了
     if (listView1.SelectedItems.Count != 0)
     {
         employeeLevel emp = new employeeLevel();
         emp.SuperiorNumber    = listView1.SelectedItems[0].SubItems[3].Text;
         emp.SubordinateNumber = listView1.SelectedItems[0].SubItems[4].Text;
         emp.MerchantNumber    = listView1.SelectedItems[0].SubItems[5].Text;
         //得到id
         string id = lab_id.Text;
         //判断是否选中了
         if (id.Length != 0 && id != "")
         {
             DialogResult dr = MessageBox.Show("您确定要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
             if (dr != DialogResult.OK)
             {
                 return;                        //点取消的代码
             }
             //得到id
             int num = Int32.Parse(id);
             emp = sql.getEmployeeLevelParent(num)[0];
             int tt = sql.setEmployeeLevelDelete(num);
             if (tt != -1)
             {
                 //调用函数,加载,刷新
                 this.dataListView("");
                 MessageBox.Show("删除成功!");
             }
             else
             {
                 MessageBox.Show("删除失败!");
             }
         }
     }
     else
     {
         MessageBox.Show("请选择要删除的员工!");
     }
 }
예제 #8
0
        /// <summary>
        /// 基础验证
        /// </summary>
        /// <param name="emp"></param>
        public employeeLevel vadata(employeeLevel emp)
        {
            emp.Id        = lab_id.Text != ""? Int32.Parse(lab_id.Text):0;
            emp.Parent_id = lab_parent_id.Text != ""?Int32.Parse(lab_parent_id.Text):0;
            emp.UserName  = txt_userName.Text;

            if ("".Equals(emp.UserName) || emp.UserName == null)
            {
                MessageBox.Show("请填写名称!"); return(null);
            }
            emp.Stock = txt_stock.Text;
            if ("".Equals(emp.Stock) || emp.Stock == null)
            {
                MessageBox.Show("请填写产品库存!"); return(null);
            }
            emp.JobNumber = txt_jobNumber.Text;
            if ("".Equals(emp.JobNumber) || emp.JobNumber == null)
            {
                MessageBox.Show("工号不能为空!"); return(null);
            }
            emp.MerchantNumber = txt_MerchantNumber.Text;
            if ("".Equals(emp.MerchantNumber) || emp.MerchantNumber == null)
            {
                MessageBox.Show("商户数量不能为空!"); return(null);
            }
            //父id
            emp.Parent_id = Int32.Parse(cob_parent_id.Text.Split('.')[0].ToString());
            List <employeeLevel> getJobNumberList = sql.getJobNumberList(emp.JobNumber);

            if (getJobNumberList.Count >= 1)
            {
                MessageBox.Show("工号重复了!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                return(null);
            }
            return(emp);
        }