Beispiel #1
0
        private void Staff_Load(object sender, EventArgs e)
        {
            timer1.Enabled    = true;
            timer1.Interval   = 1000;
            timer1.Enabled    = false;
            pictureBox1.Image = imageList1.Images[0];
            time.Text         = DateTime.Now.ToLocalTime().ToString();
            try
            {
                mysql Mysql = new mysql();
                //MySqlConnection conn = Mysql.Connection();
                string sql = @"select * from staff";

                /*DataSet ds = Mysql.GetDataSet(sql);
                 * comboBox1.DataSource = ds.Tables[0];
                 * comboBox1.DisplayMember = "name";
                 * comboBox1.ValueMember = "id";*/
                MySqlDataReader dr = Mysql.GetRead(sql);
                while (dr.Read())
                {
                    comboBox1.Items.Add(dr["name"].ToString());
                }
                dr.Close();
                //comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            }
            catch (Exception ex)
            {
                MessageBox.Show("异常为:" + ex.Message);
            }
            finally
            {
            }
        }
Beispiel #2
0
        private void Dismiss_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = imageList1.Images[0];
            timer1.Enabled    = true;
            label4.Enabled    = false;
            timer1.Interval   = 1000;
            label4.Text       = DateTime.Now.ToLocalTime().ToString();
            try
            {
                mysql           Mysql = new mysql();
                MySqlConnection conn  = Mysql.Connection();
                string          sql   = @"select * from staff";
                MySqlDataReader dr    = Mysql.GetRead(sql);

                while (dr.Read())
                {
                    comboBox1.Items.Add(dr["name"].ToString());
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally { }
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            mysql Mysql = new mysql();

            int[] arr_ID = new int[3000];          //假设最大值为3000人
            try
            {
                string          sql_id = @"select * from pay"; //依照工作号筛选每个人,通过这个给每个人依次分配工资
                MySqlDataReader dr     = Mysql.GetRead(sql_id);
                while (dr.Read())
                {
                    arr_ID[i] = int.Parse(dr["id"].ToString());
                    string sql_rest = @"select rest_holiday from pay where id=" + arr_ID[i] + "";
                    int    restday  = int.Parse(Mysql.Executescalar(sql_rest).ToString());
                    if (Mysql.Executescalar(sql_rest) != null)
                    {
                        Monthsalary = daysalary * (30 - restday);
                    }
                    string sql_total = @"update pay set salary=" + Monthsalary + " where id=" + arr_ID[i] + " ";
                    int    result    = Mysql.ExecuteNonQuery(sql_total);
                    i++;
                }
                if (i != -1)
                {
                    MessageBox.Show("分配工资成功!");
                }
                else
                {
                    MessageBox.Show("分配工资失败!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally { }
        }