Пример #1
0
        private void Initial_BaseData()
        {
            LinkSQL linksql = new LinkSQL();        //创建数据库连接

            switch (label4.Text)
            {
            case "仓储部":
                linksql.OpenSQL();
                linksql.SQLSelect(@"select content from notice where department_id = 'ST0001' order by date desc");
                BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.SQLSelect(@"select COUNT(*) from employee where department_ID = 'ST0001'");
                label6.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.SQLSelect(@"select COUNT(*) from sign,employee where SHC = 1 and employee_ID = employee.ID  and employee.department_ID = 'ST0001'");
                label8.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.SQLSelect(@"select COUNT(*)from sign,employee where sign_in = 1 and employee_ID = employee.ID  and employee.department_ID = 'ST0001'");
                label10.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.CloseSQL();
                break;

            case "采购部":
                linksql.OpenSQL();
                linksql.SQLSelect(@"select content from notice where department_id = 'PU0001' order by date desc");
                BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString(); //公告
                linksql.SQLSelect(@"select COUNT(*) from employee where department_ID = 'PU0001'");
                label6.Text = linksql.Comm.ExecuteScalar().ToString();               //
                linksql.SQLSelect(@"select COUNT(*) from sign,employee where SHC = 1 and employee_ID = employee.ID  and employee.department_ID = 'PU0001'");
                label8.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.SQLSelect(@"select COUNT(*)from sign,employee where sign_in = 1 and employee_ID = employee.ID  and employee.department_ID = 'PU0001'");
                label10.Text = linksql.Comm.ExecuteScalar().ToString();
                linksql.CloseSQL();
                break;
            }
        }
Пример #2
0
        private void Frm_Load(object sender, EventArgs e)    //加载ComboBox的一些选项
        {
            LinkSQL linksql = new LinkSQL();                 //创建数据库连接对象

            System.Data.SqlClient.SqlDataReader RD;          //创建一个对像接收查询的返回数据
            linksql.OpenSQL();                               //打开数据库
            linksql.SQLSelect(@"select ID from department"); //查询部门编号
            RD = linksql.Comm.ExecuteReader();
            while (RD.Read())
            {
                department_ID.Items.Add(Convert.ToString(RD[0]));         //将查询的结果添加到department_ID上
            }

            sex.Items.Add("男");
            sex.Items.Add("女");
            linksql.CloseSQL();                          //关闭数据库
            linksql.OpenSQL();                           //打开数据库
            linksql.SQLSelect(@"select name from post"); //查询职位
            RD = linksql.Comm.ExecuteReader();
            while (RD.Read())
            {
                post.Items.Add(Convert.ToString(RD[0]));         //将查询的结果添加到post上
            }

            linksql.CloseSQL();     //关闭数据库
        }
Пример #3
0
        private void comboBox_Check(object sender, EventArgs e)  //检查输入的数据有效性,光标离开时自动触发
        {
            LinkSQL  linksql    = new LinkSQL();
            ComboBox comboxBox1 = (ComboBox)sender;
            int      i;

            switch (comboxBox1.Name)
            {
            case "department_ID":
                linksql.OpenSQL();
                linksql.SQLSelect(@"select count(*) from department where ID = '" + department_ID.Text + "'");
                i = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                if (i != 1)
                {
                    MessageBox.Show("输入的部门不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    department_ID.SelectAll();
                }
                linksql.CloseSQL();
                break;

            case "employee_ID":
                linksql.OpenSQL();
                linksql.SQLSelect(@"select count(*) from employee where ID = '" + employee_ID.Text + "'");
                i = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                if (i != 0)
                {
                    MessageBox.Show("该员工已存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    employee_ID.SelectAll();
                }
                linksql.CloseSQL();
                break;

            case "sex":
                if (sex.Text != "男" && sex.Text != "女")
                {
                    MessageBox.Show("请选择男或女!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    sex.SelectAll();
                }
                break;

            case "post":
                linksql.OpenSQL();
                linksql.SQLSelect(@"select count(*) from employee where post = '" + employee_ID.Text + "'");
                i = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                if (i != 0)
                {
                    MessageBox.Show("该职位不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    post.SelectAll();
                }
                linksql.CloseSQL();
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// 删除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteData(object sender, EventArgs e)
        {
            DialogResult Re = MessageBox.Show("确认删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (Re == DialogResult.OK)
            {
                int     No      = int.Parse(((Button)sender).Name); //获取要删除的数据所在行
                int     y       = 0;                                //找出要删除的行
                LinkSQL linkSql = new LinkSQL();
                try
                {
                    linkSql.OpenSQL();
                }
                catch
                {
                    MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                linkSql.SQLSelect(@"select No from demand");
                System.Data.SqlClient.SqlDataReader DR = linkSql.Comm.ExecuteReader();
                while (DR.Read())
                {
                    y++;
                    if (y == No)
                    {
                        No = int.Parse(DR[0].ToString());
                    }
                }
                linkSql.CloseSQL();
                try
                {
                    linkSql.OpenSQL();
                }
                catch
                {
                    MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                linkSql.SQLInsert(@"delete demand where No = " + No.ToString());
                linkSql.SQLSelect(@"dbcc checkident('demand',reseed,0)");
                linkSql.Comm.ExecuteNonQuery();
                linkSql.CloseSQL();
                RefreshData();
            }
            else
            {
                return;
            }
        }
Пример #5
0
        private void Confirm_Click(object sender, EventArgs e)    //确认添加按钮事件
        {
            LinkSQL linksql = new LinkSQL();
            //System.Data.SqlClient.SqlDataReader RD;
            int i;

            linksql.OpenSQL();
            try
            {
                i = linksql.SQLInsert(@"insert sign(employee_ID,employee_Name) values('" + employee_ID.Text + "','" + name.Text + "')");
                if (i == 1)
                {
                    i = linksql.SQLInsert(@"insert employee values('" + department_ID.Text + "','" + employee_ID.Text + "','" + name.Text + "','" + sex.Text + "'," + float.Parse(wages.Text) + ",'" + IDCard.Text + "','" + address.Text + "','" + telephone.Text + "','" + post.Text + "','" + DateTime.Now.ToString() + "')");
                    if (i == 1)
                    {
                        MessageBox.Show("添加成功!", "提示"); this.Close();
                    }
                    else
                    {
                        MessageBox.Show("添加失败", "提示"); return;
                    }
                }
                else
                {
                    MessageBox.Show("添加失败!", "提示"); return;
                }
            }
            catch
            {
                MessageBox.Show("添加失败,请检查您输入的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }
            linksql.CloseSQL();
        }
Пример #6
0
        private void BulletinContentChange_Click(object sender, EventArgs e)   //当光标离开公告栏的textBox时发生
        {
            LinkSQL      linksql = new LinkSQL();
            DialogResult dr      = MessageBox.Show("确认修改?", "修改公告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

            if (dr == DialogResult.OK)
            {
                try
                {
                    linksql.OpenSQL();       //打开数据库
                    int i = 0;
                    if (label4.Text == "采购部")
                    {
                        i = linksql.SQLInsert(@"insert notice values('PU0001',GETDATE(),'" + BulletinBoardCententText.Text + "')");
                    }
                    if (label4.Text == "仓储部")
                    {
                        i = linksql.SQLInsert(@"insert notice values('ST0001',GETDATE(),'" + BulletinBoardCententText.Text + "')");
                    }
                    if (i > 0)
                    {
                        MessageBox.Show("修改成功!", "修改结果");
                        if (label4.Text == "采购部")
                        {
                            linksql.SQLSelect(@"select content from notice where department_id = 'PU0001' order by date desc");
                            BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString();
                        }
                        if (label4.Text == "仓储部")
                        {
                            linksql.SQLSelect(@"select content from notice where department_id = 'ST0001' order by date desc");
                            BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("修改失败!请重新修改!", "修改结果", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                    linksql.CloseSQL();
                }
                catch
                {
                    string str = BulletinBoardCententText.Text;
                    dr = MessageBox.Show("本次修改将不进行保存,是否依然修改?", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                    if (dr == DialogResult.OK)
                    {
                        BulletinBoardCentent.Text = str;
                    }
                }
                BulletinBoardCentent.Visible     = true;
                BulletinBoardCententText.Visible = false;
                updateNotice.Text = "修改公告";
            }
            else
            {
                MessageBox.Show("修改失败!您取消了修改!", "修改提示");
                BulletinBoardCentent.Visible     = true;
                BulletinBoardCententText.Visible = false;
                updateNotice.Text = "修改公告";
            }
        }
Пример #7
0
 private void LoadData(string sqlSelectStr, ComboBox C)   //加载检索数据
 {
     System.Data.SqlClient.SqlDataReader dataRead;
     C.Items.Clear();                         //清空原数据
     linkSql.OpenSQL();                       //打开数据库
     linkSql.SQLSelect(sqlSelectStr);         //执行查询
     dataRead = linkSql.Comm.ExecuteReader(); //
     while (dataRead.Read())
     {
         int    i = 0;
         string s = "";
         s = (string)dataRead[i]; //记录下数据库中返回的内容
         C.Items.Add(s);          //将数据添到控件的选项中
         i++;
     }
     linkSql.CloseSQL();  //关闭数据库
 }
Пример #8
0
        /// <summary>
        /// 查询按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string selectStr = "select * from applicants";

            LinkSQL linkSql = new LinkSQL();

            linkSql.OpenSQL();

            linkSql.CloseSQL();
        }
Пример #9
0
        /// <summary>
        /// 初始化表格或刷新表格数据
        /// </summary>
        private void InitializeData()
        {
            foreach (Control a in panel1.Controls)
            {
                if (a.GetType().Name == "Button")
                {
                    a.Visible = false;
                }
            }
            LinkSQL linkSql = new LinkSQL();

            System.Data.SqlClient.SqlDataReader DR;  //TODO:载入表格数据
            linkSql.OpenSQL();
            linkSql.SQLSelect("select *from demand");
            DR = linkSql.Comm.ExecuteReader();
            int i = 0;

            while (DR.Read())
            {
                panel1.Controls.Add(delButton[i]);
                panel1.Controls.Add(alterButton[i]);
                for (int j = 0; j < table.GetLength(1); j++)
                {
                    table[i, j].Visible = true;
                    table[i, j].Text    = DR[j].ToString();
                    if (DR[j].ToString() == "PU0001")
                    {
                        table[i, j].Text = "采购部";
                    }
                    if (DR[j].ToString() == "ST0001")
                    {
                        table[i, j].Text = "仓储部";
                    }
                    if (j == table.GetLength(1) - 1)
                    {
                        detail[i]        = table[i, j].Text;                       //把完整的介绍提取出来
                        table[i, j].Size = new Size(350, 33);
                        if (table[i, j].Text.Length > 18)                          //将详细介绍收缩
                        {
                            table[i, j].Text  = table[i, j].Text.Substring(0, 18); //截断字符串
                            table[i, j].Text += "...";
                        }
                    }
                    if (j == 0)
                    {
                        table[i, j].Text = (i + 1).ToString();
                    }
                }
                i++;
            }
            linkSql.CloseSQL();
        }
Пример #10
0
        /// <summary>
        /// 修改按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AlterButton_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            CententForm.Employee.WinForm.AddDemand addDemand = new CententForm.Employee.WinForm.AddDemand();
            int     buttonName = int.Parse(((Button)sender).Name);//获取要修改的数据所在行
            int     No         = 0;
            int     y          = 0;
            LinkSQL linkSql    = new LinkSQL();

            try
            {
                linkSql.OpenSQL();
            }
            catch
            {
                MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            linkSql.SQLSelect(@"select No from demand");
            System.Data.SqlClient.SqlDataReader DR = linkSql.Comm.ExecuteReader();
            while (DR.Read())
            {
                if (buttonName == y)
                {
                    No = int.Parse(DR[0].ToString());
                }
                y++;
            }
            addDemand.UpDataNo           = No;
            addDemand.Department_ID.Text = table[buttonName, 1].Text;
            if (table[buttonName, 1].Text == "采购部")
            {
                addDemand.Department_ID.Text = "PU0001";
            }
            if (table[buttonName, 1].Text == "仓储部")
            {
                addDemand.Department_ID.Text = "ST0001";
            }
            addDemand.Post.Text       = table[buttonName, 2].Text;
            addDemand.Rec_Number.Text = table[buttonName, 3].Text;
            addDemand.Explain.Text    = detail[buttonName];
            DialogResult dr = addDemand.ShowDialog();

            if (dr == DialogResult.Cancel)
            {
                RefreshData();
            }
            else
            {
                return;
            }
        }
Пример #11
0
        private void ID_Check(object sender, EventArgs e) //身份证号码检索
        {
            LinkSQL linksql = new LinkSQL();
            int     i;

            linksql.OpenSQL();
            linksql.SQLSelect(@"select count(*) from employee where ID_card = '" + IDCard.Text + "'");
            i = int.Parse(linksql.Comm.ExecuteScalar().ToString());
            if (i != 0)
            {
                MessageBox.Show("该员工已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
                IDCard.SelectAll();
            }
            linksql.CloseSQL();
        }
Пример #12
0
        private void DepartmentTextChange_Click(object sender, EventArgs e)
        {
            post.Items.Clear();
            LinkSQL linksql = new LinkSQL();                                                              //创建数据库连接对象

            System.Data.SqlClient.SqlDataReader RD;                                                       //创建一个对像接收查询的返回数据
            linksql.OpenSQL();                                                                            //打开数据库
            linksql.SQLSelect(@"select name from post where department_ID='" + department_ID.Text + "'"); //查询职位
            RD = linksql.Comm.ExecuteReader();
            while (RD.Read())
            {
                post.Items.Add(Convert.ToString(RD[0]));         //将查询的结果添加到post上
            }

            linksql.CloseSQL();     //关闭数据库
        }
Пример #13
0
        private System.Data.SqlClient.SqlDataReader AlterSelect()//根据部门选择查询
        {
            LinkSQL linksql = new LinkSQL();

            //System.Data.SqlClient.SqlDataReader dr;

            switch (label4.Text)        //根据部门选择查询
            {
            case "采购部":
                linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001'");
                break;

            case "仓储部":
                linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001'");
                break;
            }
            linksql.OpenSQL();
            return(linksql.Comm.ExecuteReader());
        }
Пример #14
0
        /// <summary>
        /// 添加需求事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            int number = 22;  //记录当前的需求信息的数量

            try
            {
                LinkSQL linkSql = new LinkSQL();
                linkSql.OpenSQL();
                linkSql.SQLSelect(@"select count(*) from demand");
                number = int.Parse(linkSql.Comm.ExecuteScalar().ToString());
                linkSql.CloseSQL();
            }
            catch
            {
                MessageBox.Show("无法连接到服务器!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (number >= 20)
            {
                MessageBox.Show("最大只可发布20条招聘信息,请先删除部分的招聘信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (number == 22)
            {
                MessageBox.Show("无法连接到服务器!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            CententForm.Employee.WinForm.AddDemand addDemand = new CententForm.Employee.WinForm.AddDemand();
            DialogResult dr = addDemand.ShowDialog();

            if (dr == DialogResult.Cancel)
            {
                RefreshData();
            }
            else
            {
                return;
            }
        }
Пример #15
0
        /// <summary>
        /// 管理员登陆验证
        /// </summary>
        /// <param name="id">用户名</param>
        /// <param name="root">密码</param>
        /// <returns></returns>
        private int CheckAdminLand(string id, string root)
        {
            LinkSQL landLinkSQL = new LinkSQL();

            try
            {
                landLinkSQL.OpenSQL();
            }
            catch
            {
                MessageBox.Show("连接服务器失败");    //打开数据库失败
                Application.Exit();
            }
            string T_SQL;
            int    value = 0;

            T_SQL = "select count(*) from theUser where ID = '" + id + "' and Password = '******'" + " and theidentity = '管理员'";
            landLinkSQL.SQLSelect(T_SQL);
            value = (int)landLinkSQL.Comm.ExecuteScalar();
            if (value == 0)
            {
                landLinkSQL.CloseSQL();
                MessageBox.Show("您输入的用户名或密码错误,请重新输入");
                return(0);
            }
            else
            if (value == 1)
            {
                landLinkSQL.CloseSQL();
                return(1);
            }

            else
            {
                landLinkSQL.CloseSQL();
                MessageBox.Show("异常错误");
                return(0);
            }
        }
Пример #16
0
        /// <summary>
        /// 普通用户登陆
        /// </summary>
        /// <param name="id">用户名</param>
        /// <param name="root">密码</param>
        /// <returns></returns>
        private int CheckUserLand(string id, string root)     //普通用户登陆验证
        {
            LinkSQL LandLinkSql = new LinkSQL();

            try
            {
                LandLinkSql.OpenSQL();
            }
            catch
            {
                MessageBox.Show("打开连接服务器失败!");    //打开数据库失败
                Application.Exit();
            }

            string Sql;

            Sql = "select count(*) from theUser where ID = '" + id + "' and Password = '******'" + " and theidentity = '普通用户'";
            int Value;

            LandLinkSql.SQLSelect(Sql);
            Value = (int)LandLinkSql.Comm.ExecuteScalar();
            if (Value == 0)
            {
                MessageBox.Show("您输入的用户名或密码错误,请重新输入");
                return(0);
            }
            else
            if (Value == 1)
            {
                LandLinkSql.CloseSQL();
                return(1);
            }

            else
            {
                MessageBox.Show("异常错误");
                return(0);
            }
        }
Пример #17
0
        private void LookUp1_Click(object sender, EventArgs e) //部门人数查看,修改按钮事件
        {
            int z = 0; count = 0;                              //z格式控制,count数据的行数

            Initial_Data();                                    //初始化表格
            tableHead[0].Text = "";
            tableHead[1].Text = "员工编号";
            tableHead[2].Text = "姓名";
            tableHead[3].Text = "姓别";
            tableHead[4].Text = "职位";
            foreach (Label a in tableHead)
            {
                a.Visible = true;
            }
            LinkSQL linksql = new LinkSQL();    //创建数据库连接对像linksql

            System.Data.SqlClient.SqlDataReader RD;
            linksql.OpenSQL();    //打开数据库
            switch (label4.Text)  //根据部门选择查询
            {
            case "采购部":
                linksql.SQLSelect(@"select ID,Name,sex,post from employee where department_Id = 'PU0001'");
                break;

            case "仓储部":
                linksql.SQLSelect(@"select ID,Name,sex,post from employee where department_Id = 'ST0001'");
                break;
            }
            RD = linksql.Comm.ExecuteReader(); //接收查询结果
            while (RD.Read())                  //输入查询结果 TODO:暂时只能输出十六条数据
            {
                count++;
                if (count <= 8)              //小于8行,用表1记录
                {
                    for (int i = 0; i < RD.FieldCount; i++)
                    {
                        tableLabel1[z].Text            = ((z / 5) + 1).ToString();
                        tableLabel1[z].Visible         = true;
                        tableLabel1[i + z + 1].Text    = Convert.ToString(RD[i]);
                        tableLabel1[i + z + 1].Visible = true;
                    }
                }
                if (count % 8 == 0)
                {
                    z = 0;
                }
                if (count > 8 && count <= 16)           //8-16行用表2记录
                {
                    z = 0;
                    for (int i = 0; i < RD.FieldCount; i++)
                    {
                        tableLabel2[z].Text            = (((z / 5) + 1) + 8).ToString();
                        tableLabel2[z].Visible         = false;
                        tableLabel2[i + z + 1].Text    = Convert.ToString(RD[i]);
                        tableLabel2[i + z + 1].Visible = false;
                    }
                }

                z += 5;
            }
            pageNow.Text = "1";                          //当前页码
            pageAll.Text = ((count / 9) + 1).ToString(); //总页面数量

            linksql.CloseSQL();                          //闭关数据库
            //if (((Button)sender).Name == "lookUp1")
            //{
            if (int.Parse(pageAll.Text) > 1)
            {
                pageUp.Visible   = true;
                pageDown.Visible = true;
                MessageBox.Show("共" + pageAll.Text + "页");
            }
            //}
            if (((Button)sender).Name == "alter1")
            {
                add.Visible     = true;
                callOff.Visible = true;
            }
        }
Пример #18
0
        private void AddData()
        {
            int     i = 0, k = 0; //i记录影响行数,K记录重复行数
            string  insertStr = @"insert demand values('" + department_ID.Text + "','" + post.Text + "'," + rec_Number.Text + ",'" + explain.Text + "')";
            LinkSQL linksql   = new LinkSQL();

            try
            {
                linksql.OpenSQL();
                linksql.SQLSelect("select count(*) from demand where post = '" + post.Text + "'");
                k = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                linksql.SQLSelect("select NO from demand where post = '" + post.Text + "'");
                linksql.CloseSQL();//关闭连接
                if (k == 0)
                {
                    linksql.OpenSQL();  //打开连接
                    i = linksql.SQLInsert(insertStr);
                    linksql.CloseSQL(); //关闭连接
                }
                else
                {
                    linksql.OpenSQL();//打开连接
                    My.MyMessageBox messageBox = new My.MyMessageBox();
                    messageBox.Show("该信息已存在,是否修改招聘信息?", "提示", My.MyMessageBox.MyMessageBoxButton.OKCancel, My.MyMessageBox.MyMessageBoxIcon.Question);
                    DialogResult DR = messageBox.DialogResult;
                    if (DR == DialogResult.Cancel)
                    {
                        this.Close();
                    }
                    else
                    {
                        //upDateNO = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                        string upDateStr = @"update demand set department_id = '" + department_ID.Text + "',post = '" + post.Text + "',rec_Number = " + rec_Number.Text + ",exlain = '" + explain.Text + "' where NO = " + upDateNO.ToString();
                        i = linksql.SQLInsert(upDateStr);
                    }
                    linksql.CloseSQL();//关闭连接
                }
            }
            catch       //插入或更新出错尝试重新插入更新(20次)
            {
                linksql.CloseSQL();
                linksql.OpenSQL();//打开连接
                //upDateNO = int.Parse(linksql.Comm.ExecuteScalar().ToString());
                string upDateStr = @"update demand set department_id = '" + department_ID.Text + "',post = '" + post.Text + "',rec_Number = " + rec_Number.Text + ",exlain = '" + explain.Text + "' where NO = " + upDateNO.ToString();
                for (int x = 0; x < 20; x++)
                {
                    try
                    {
                        if (k == 0)
                        {
                            i = linksql.SQLInsert(insertStr); break;
                        }
                        else
                        {
                            i = linksql.SQLInsert(upDateStr);
                        }
                    }
                    catch { continue; }
                }
                linksql.CloseSQL();
                if (i == 1)
                {
                    MessageBox.Show("添加成功!", "提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("插入失败,请重试!如多次提示,请尝试删除一个招聘信息后再次修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                return;
            }
            linksql.CloseSQL();
            if (i == 1)//判断添加数据结果
            {
                MessageBox.Show("添加成功!", "提示");
                this.Close();
            }
            else
            {
                MessageBox.Show("插入失败,请重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #19
0
        /// <summary>
        /// 确认提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            /// <summary>受影响的行数 </summary>
            int     infRow  = 0; //受影响的行数
            int     repeat  = 0; //重复的数据数
            LinkSQL linkSql = new LinkSQL();

            try
            {
                try
                {
                    //--------------------
                    linkSql.OpenSQL();
                    linkSql.SQLSelect(@"select count(*) from applicants where ID_card = '" + id.Text + "' ");
                    repeat = int.Parse(linkSql.Comm.ExecuteScalar().ToString());
                    linkSql.Conn.Dispose();
                    linkSql.Comm.Dispose();
                    linkSql.CloseSQL();
                    //----------------------查询库中是否已存在数据
                }
                catch { MessageBox.Show("无法连接服务器,请重试"); return; }
                if (repeat == 0)
                {
                    linkSql.OpenSQL();
                    string insertStr = "insert into applicants values('" + name.Text + "','" + sex.Text + "'," + age.Text + ",'" + id.Text + "','" + post.Text + "','" + joinTime.Text + "')";
                    infRow = linkSql.SQLInsert(insertStr);
                    linkSql.Comm.Dispose();
                    linkSql.Conn.Dispose();
                    linkSql.CloseSQL();
                }
                else
                {
                    MessageBox.Show("已存在此人,请勿插入重复数据!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return;
                }
            }
            catch
            {
                MessageBox.Show("插入失败,请重试!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                linkSql.Conn.Dispose();
                linkSql.Comm.Dispose();
            }
            if (infRow == 1)
            {
                MessageBox.Show("添加成功!", "提示");
                foreach (Control a in this.Controls)
                {
                    if (a.GetType().Name == "TextBox")
                    {
                        a.Text = "";
                    }
                }
            }
            else
            {
                MessageBox.Show("添加失败", "提示");
                return;
            }
        }
Пример #20
0
        private void LookUp2_Click(object sender, EventArgs e)      //应到、签到人数查看按钮事件
        {
            Initial_Data();
            foreach (Label a in tableHead)
            {
                a.Visible = true;
            }
            int z = 0;

            count = 0;                       //z格式控制,count数据的行数
            //--------------------------------------以上为初始化---------------------------//
            LinkSQL linksql = new LinkSQL(); //创建数据库连接对像linksql

            System.Data.SqlClient.SqlDataReader RD;

            linksql.OpenSQL();
            switch (((Button)sender).Name)   //判断引发事件的按钮
            {
            case "callOff":
            case "lookUp2":             //应到人员
                switch (label4.Text)    //根据部门选择查询
                {
                case "采购部":

                    linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001' and (shc=1 or shc=2)");
                    break;

                case "仓储部":
                    linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001' and (shc=1 or shc=2)");
                    break;
                }
                break;

            case "lookUp3":                 //实到人员
                switch (label4.Text)        //根据部门选择查询
                {
                case "采购部":

                    linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001' and (sign_in=1 or sign_in=2)");
                    break;

                case "仓储部":
                    linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001' and (sign_in=1 or sign_in=2)");
                    break;
                }
                break;
            }
            RD = linksql.Comm.ExecuteReader();
            while (RD.Read())
            {
                count++;
                if (count <= 8)
                {
                    for (int i = 0; i < RD.FieldCount; i++)
                    {
                        tableLabel1[i + z].Visible = true;
                        switch (i)
                        {
                        case 0:
                        case 1:
                            //tableLabel1[i + z].Visible = true;
                            tableLabel1[i + z].Text = Convert.ToString(RD[i]);
                            break;

                        case 2:
                        case 3:
                            switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                            {
                            //tableLabel1[i + z].Visible = true;
                            case 0:
                                tableLabel1[i + z].Text = "×";
                                break;

                            case 1:
                                tableLabel1[i + z].Text = "√";
                                break;

                            case 2:
                                tableLabel1[i + z].Text = "○";
                                break;
                            }
                            break;

                        case 4:
                            tableLabel1[i + z].Text = Convert.ToString(RD[i]);
                            break;
                        }
                    }
                }
                if (count % 8 == 0)    //新的一页重置格式控制
                {
                    z = -5;
                }

                if (count > 8 && count <= 16)
                {
                    for (int i = 0; i < RD.FieldCount; i++)
                    {
                        tableLabel2[i + z].Visible = false;
                        //tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                        switch (i)
                        {
                        case 0:
                        case 1:
                            //tableLabel1[i + z].Visible = true;
                            tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                            break;

                        case 2:
                        case 3:
                            switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                            {
                            //tableLabel1[i + z].Visible = true;
                            case 0:
                                tableLabel2[i + z].Text = "×";
                                break;

                            case 1:
                                tableLabel2[i + z].Text = "√";
                                break;

                            case 2:
                                tableLabel2[i + z].Text = "○";
                                break;
                            }
                            break;

                        case 4:
                            tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                            break;
                        }
                    }
                }
                z += 5;
            }
            linksql.CloseSQL();                          //闭关数据库
            pageNow.Text = "1";                          //当前页码
            pageAll.Text = ((count / 9) + 1).ToString(); //总页面数量
            if (int.Parse(pageAll.Text) > 1)
            {
                pageUp.Visible   = true;
                pageDown.Visible = true;
                MessageBox.Show("共" + pageAll.Text + "页");
            }
            if (((Button)sender).Name == "alter2")
            {
                putIn.Visible   = true;
                callOff.Visible = true;
            }
        }
Пример #21
0
        private void PutIn_Click(Label[] tableLabel)//确认提交
        {
            int index = 0;

            string[] tablelabelName = new string[16];
            int[]    tableboxValue  = new int[16];

            while (textBoxName[index] != null)
            {
                switch (textBoxName[index])
                {
                case "tableTextBox1_0":
                    tableboxValue[index]  = int.Parse(tableTextBox1[0].Text);
                    tablelabelName[index] = tableLabel[0].Text;
                    break;

                case "tableTextBox1_1":
                    tableboxValue[index]  = int.Parse(tableTextBox1[1].Text);
                    tablelabelName[index] = tableLabel[0].Text;
                    break;

                case "tableTextBox1_2":
                    tableboxValue[index]  = int.Parse(tableTextBox1[2].Text);
                    tablelabelName[index] = tableLabel[5].Text;
                    break;

                case "tableTextBox1_3":
                    tableboxValue[index]  = int.Parse(tableTextBox1[3].Text);
                    tablelabelName[index] = tableLabel[5].Text;
                    break;

                case "tableTextBox1_4":
                    tableboxValue[index]  = int.Parse(tableTextBox1[4].Text);
                    tablelabelName[index] = tableLabel[10].Text;
                    break;

                case "tableTextBox1_5":
                    tableboxValue[index]  = int.Parse(tableTextBox1[5].Text);
                    tablelabelName[index] = tableLabel[10].Text;
                    break;

                case "tableTextBox1_6":
                    tableboxValue[index]  = int.Parse(tableTextBox1[6].Text);
                    tablelabelName[index] = tableLabel[15].Text;
                    break;

                case "tableTextBox1_7":
                    tableboxValue[index]  = int.Parse(tableTextBox1[7].Text);
                    tablelabelName[index] = tableLabel[15].Text;
                    break;

                case "tableTextBox1_8":
                    tableboxValue[index]  = int.Parse(tableTextBox1[8].Text);
                    tablelabelName[index] = tableLabel1[20].Text;
                    break;

                case "tableTextBox1_9":
                    tableboxValue[index]  = int.Parse(tableTextBox1[9].Text);
                    tablelabelName[index] = tableLabel1[20].Text;
                    break;

                case "tableTextBox1_10":
                    tableboxValue[index]  = int.Parse(tableTextBox1[10].Text);
                    tablelabelName[index] = tableLabel1[25].Text;
                    break;

                case "tableTextBox1_11":
                    tableboxValue[index]  = int.Parse(tableTextBox1[11].Text);
                    tablelabelName[index] = tableLabel1[25].Text;
                    break;

                case "tableTextBox1_12":
                    tableboxValue[index]  = int.Parse(tableTextBox1[12].Text);
                    tablelabelName[index] = tableLabel1[30].Text;
                    break;

                case "tableTextBox1_13":
                    tableboxValue[index]  = int.Parse(tableTextBox1[13].Text);
                    tablelabelName[index] = tableLabel1[30].Text;
                    break;

                case "tableTextBox1_14":
                    tableboxValue[index]  = int.Parse(tableTextBox1[14].Text);
                    tablelabelName[index] = tableLabel1[35].Text;
                    break;

                case "tableTextBox1_15":
                    tableboxValue[index]  = int.Parse(tableTextBox1[15].Text);
                    tablelabelName[index] = tableLabel1[35].Text;
                    break;
                }
                index++;
            }
            DialogResult dr = MessageBox.Show("确认提交信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.OK)
            {
                int     x = 0, sum = 0;
                LinkSQL linksql = new LinkSQL();
                linksql.OpenSQL();
                for (int i = 0; tablelabelName[i] != null /*tableTextBox1[i * 2].Visible == true*/; i++)
                {
                    foreach (Label a in tableLabel1)
                    {
                        if (a.Text == tablelabelName[i])
                        {
                            if (label12.Text == "alter2")    //判断当前触修改的列
                            {
                                x += linksql.SQLInsert(@"update sign set SHC = " + tableboxValue[i] + " where employee_ID = '" + a.Text + "'");
                            }
                            if (label12.Text == "alter3")    //判断当前触修改的列
                            {
                                x += linksql.SQLInsert(@"update sign set sign_in = " + tableboxValue[i] + " where employee_ID = '" + a.Text + "'");
                            }
                        }
                    }
                    foreach (Label a in tableLabel2)
                    {
                        if (a.Text == tablelabelName[i])
                        {
                            if (label12.Text == "alter2")    //判断当前触修改的列
                            {
                                x += linksql.SQLInsert(@"update sign set SHC = " + tableboxValue[i] + " where employee_ID = '" + a.Text + "'");
                            }
                            if (label12.Text == "alter3")    //判断当前触修改的列
                            {
                                x += linksql.SQLInsert(@"update sign set sign_in = " + tableboxValue[i] + " where employee_ID = '" + a.Text + "'");
                            }
                        }
                    }
                    sum += 1;
                }
                linksql.CloseSQL();
                if (sum == x && sum != 0)
                {
                    MessageBox.Show("修改成功", "修改结果");
                }
                else if (sum != 0 && (sum - x) == 0)
                {
                    MessageBox.Show("修改失败", "修改结果");
                }
                else if (sum == 0)
                {
                    MessageBox.Show("未发生改变", "提示");
                }
                else
                {
                    MessageBox.Show("出现故障,请自行检查!\n修改成功" + x.ToString() + "条," + (sum - x).ToString() + "条", "修改结果", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                return;
            }
            s = 0;
            foreach (TextBox a in tableTextBox1)
            {
                a.Leave       -= TextBoxLevel_Click;
                a.TextChanged -= TextBoxChange_Click;
            }

            Initial_Data();
            Initial_BaseData();     //刷新显示
            textBoxName = new string[16];
        }
Пример #22
0
        private void Alter2_Click(object sender, EventArgs e)   //应到签到修改按钮事件
        {
            Initial_Data();
            foreach (Label a in tableHead)
            {
                a.Visible = true;
            }
            putIn.Visible   = true;
            callOff.Visible = true;
            LinkSQL linksql = new LinkSQL();

            System.Data.SqlClient.SqlDataReader RD;
            int z = 0;      //行控制

            count = 0;      //清空记录
            //AlterSelect(); //根据部门选择查询
            if (((Button)sender).Name == "alter2")
            {
                //linksql.OpenSQL();
                label12.Text = ((Button)sender).Name.ToString();
                RD           = AlterSelect();
                while (RD.Read())
                {
                    count++;
                    if (count <= 8)
                    {
                        for (int i = 0; i < RD.FieldCount; i++)
                        {
                            tableLabel1[i + z].Visible = true;
                            switch (i)
                            {
                            case 0:
                            case 1:
                                tableLabel1[i + z].Visible = true;
                                tableLabel1[i + z].Text    = Convert.ToString(RD[i]);
                                break;

                            case 2:
                                tableTextBox1[(count - 1) * 2].Visible = true;
                                tableTextBox1[(count - 1) * 2].Text    = Convert.ToString(RD[i]);
                                tableLabel1[i + z].Visible             = false;
                                break;

                            case 3:
                                switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                                {
                                //tableLabel1[i + z].Visible = true;
                                case 0:
                                    tableLabel1[i + z].Text = "×";
                                    break;

                                case 1:
                                    tableLabel1[i + z].Text = "√";
                                    break;

                                case 2:
                                    tableLabel1[i + z].Text = "○";
                                    break;
                                }
                                break;

                            case 4:
                                tableLabel1[i + z].Text = Convert.ToString(RD[i]);
                                break;
                            }
                        }
                    }
                    if (count % 8 == 0)   //新的一页重置格式控制
                    {
                        z = -5;
                    }

                    if (count > 8 && count <= 16)
                    {
                        for (int i = 0; i < RD.FieldCount; i++)
                        {
                            //tableLabel2[i + z].Visible = true;
                            switch (i)
                            {
                            case 0:
                            case 1:
                                //tableLabel1[i + z].Visible = true;
                                tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                                break;

                            case 2:
                            case 3:
                                switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                                {
                                //tableLabel1[i + z].Visible = true;
                                case 0:
                                    tableLabel2[i + z].Text = "×";
                                    break;

                                case 1:
                                    tableLabel2[i + z].Text = "√";
                                    break;

                                case 2:
                                    tableLabel2[i + z].Text = "○";
                                    break;
                                }
                                break;

                            case 4:
                                tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                                break;
                            }
                        }
                    }
                    z += 5;
                }
                linksql.CloseSQL();
            }
            if (((Button)sender).Name == "alter3")
            {
                label12.Text = ((Button)sender).Name.ToString();
                count        = 0;
                linksql.OpenSQL();
                RD = AlterSelect();
                //int j = 0;
                while (RD.Read())
                {
                    count++;
                    if (count <= 8)
                    {
                        for (int i = 0; i < RD.FieldCount; i++)
                        {
                            tableLabel1[i + z].Visible = true;
                            switch (i)
                            {
                            case 0:
                            case 1:
                                tableLabel1[i + z].Visible = true;
                                tableLabel1[i + z].Text    = Convert.ToString(RD[i]);
                                break;

                            case 2:
                                switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                                {
                                //tableLabel1[i + z].Visible = true;
                                case 0:
                                    tableLabel1[i + z].Text = "×";
                                    break;

                                case 1:
                                    tableLabel1[i + z].Text = "√";
                                    break;

                                case 2:
                                    tableLabel1[i + z].Text = "○";
                                    break;
                                }
                                tableLabel1[i + z].Visible = true;
                                break;

                            case 3:
                                tableLabel1[i + z].Visible           = false;
                                tableTextBox1[count * 2 - 1].Visible = true;
                                tableTextBox1[count * 2 - 1].Text    = Convert.ToString(RD[i]);
                                //j++;

                                break;

                            case 4:
                                tableLabel1[i + z].Text = Convert.ToString(RD[i]);
                                break;
                            }
                        }
                    }
                    if (count % 8 == 0)   //新的一页重置格式控制
                    {
                        z = -5;
                    }

                    if (count > 8 && count <= 16)
                    {
                        //j = 0;
                        for (int i = 0; i < RD.FieldCount; i++)
                        {
                            //tableLabel2[i + z].Visible = true;
                            switch (i)
                            {
                            case 0:
                            case 1:
                                //tableLabel1[i + z].Visible = true;
                                tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                                break;

                            case 2:
                                switch (Convert.ToInt16(RD[i]))           //判断上班的值:0为不用上班,1为正常上班,2为特殊情况  签到:0为未签到,1为已签到,2为请假
                                {
                                //tableLabel1[i + z].Visible = true;
                                case 0:
                                    tableLabel2[i + z].Text = "×";
                                    break;

                                case 1:
                                    tableLabel2[i + z].Text = "√";
                                    break;

                                case 2:
                                    tableLabel2[i + z].Text = "○";
                                    break;
                                }
                                break;

                            case 3:
                            case 4:
                                tableLabel2[i + z].Text = Convert.ToString(RD[i]);
                                break;
                            }
                        }
                    }
                    z += 5;
                }
                linksql.CloseSQL();
            }
            pageNow.Text = "1";                          //当前页码
            pageAll.Text = ((count / 9) + 1).ToString(); //总页面数量
            if (int.Parse(pageAll.Text) > 1)
            {
                pageUp.Visible   = true;
                pageDown.Visible = true;
                //MessageBox.Show("共" + pageAll.Text + "页");
            }
            foreach (TextBox a in tableTextBox1)
            {
                a.TextChanged += TextBoxChange_Click;
            }
        }