示例#1
0
        private void btn_close_Click(object sender, EventArgs e)
        {
            frm_tsukibetsurisuto fm = new frm_tsukibetsurisuto();

            this.Hide();
            fm.Show();
        }
示例#2
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            string cs = File.ReadAllText(@"c:\Debug\sql.txt");

            //string cs = @"Server=localhost;userId=root;password=root;database=mbnippo";
            if (txt_Userid.Text == "")
            {
                MessageBox.Show("社員ID を 入力してください");
                txt_Userid.Focus();
                return;
            }
            if (txt_Userid.Text.Length > 10)
            {
                 
                MessageBox.Show("社員ID は 10字 以上 入力 不可能!");

                txt_Userid.Focus();
                return;
            }
            if (txt_Password.Text == "")
            {
                MessageBox.Show("パスワード を 入力してください");
                txt_Password.Focus();
                return;
            }
            if (txt_Userid.Text.Length > 12)
            {
                MessageBox.Show("パスワード は 12字 以上 入力 不可能!");
                txt_Password.Focus();
                return;
            }
            try
            {
                //Create SqlConnection
                MySqlConnection con = new MySqlConnection(cs);
                MySqlCommand    cmd = new MySqlCommand("Select * from Employee where EmpId=@username and Password=@password", con);
                cmd.Parameters.AddWithValue("@username", txt_Userid.Text);
                cmd.Parameters.AddWithValue("@password", txt_Password.Text);
                MySqlDataAdapter adapt = new MySqlDataAdapter(cmd);
                DataSet          ds    = new DataSet();
                adapt.Fill(ds);
                con.Close();
                int Count = ds.Tables[0].Rows.Count;
                if (Count != 0)
                {
                    String userid   = ds.Tables[0].Rows[0]["EmpId"].ToString();
                    String password = ds.Tables[0].Rows[0]["Password"].ToString();
                    if (userid == "AD001" && password == txt_Password.Text)
                    {
                        MessageBox.Show("ログイン が 成功しました!");
                        this.Hide();
                        username = txt_Userid.Text;
                        frm_shaiinrisuto fm = new frm_shaiinrisuto();
                        fm.Show();
                    }
                    else if (userid == txt_Userid.Text && password == txt_Password.Text)
                    {
                        MessageBox.Show("ログイン が 成功しました!");
                        this.Hide();
                        username = txt_Userid.Text;
                        frm_tsukibetsurisuto fm = new frm_tsukibetsurisuto();
                        fm.Show();
                    }
                }
                else
                {
                    MessageBox.Show("社員ID また パスワードは正しくありません!");
                    txt_Userid.Clear();
                    txt_Password.Clear();
                    txt_Userid.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        private void btn_Nippotouroku_Click(object sender, EventArgs e)
        {
            string connectionString = File.ReadAllText(@"c:\Debug\sql.txt");

            if (txt_Shukkinjikan.Text == "")
            {
                MessageBox.Show("出勤時間 を 入力してください");
                txt_Shukkinjikan.Focus();
                return;
            }
            if (txt_Taikinjikan.Text == "")
            {
                MessageBox.Show("退勤時間 を 入力してください");
                txt_Taikinjikan.Focus();
                return;
            }
            if (txt_Kyukeijikan.Text == "")
            {
                MessageBox.Show("休憩時間 を 入力してください");
                txt_Kyukeijikan.Focus();
                return;
            }
            if (txt_gyomunaiyou.Text == "")
            {
                MessageBox.Show("業務内容 を 入力してください");
                txt_gyomunaiyou.Focus();
                return;
            }
            if (dateTimePicker1.Value == null)
            {
                MessageBox.Show("日付 を 選択してください");
                txt_gyomunaiyou.Focus();
                return;
            }
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                using (MySqlCommand Command = connection.CreateCommand())
                {
                    if (updateFlg)
                    {
                        Command.CommandText = "DELETE FROM Attendance WHERE date = @edit_date ";
                        Command.Parameters.AddWithValue("@edit_date", edit_date);
                        Command.Connection.Open();
                        Command.ExecuteNonQuery();
                        Command.Connection.Close();
                    }
                    Command.CommandText = "INSERT Attendance (date,EmpId,starttime,endtime,break,comment,created_by,created_at,updated_by,updated_at) VALUES (@date,@Empid, @Shukkinjikan, @Taikinjikan,@Kyukeijikan,@gyomunaiyou,@username,'" + DateTime.Now.ToString() + "',@username,'" + DateTime.Now.ToString() + "') ";
                    Command.Parameters.AddWithValue("@date", dateTimePicker1.Value);
                    Command.Parameters.AddWithValue("@Shukkinjikan", txt_Shukkinjikan.Text);
                    Command.Parameters.AddWithValue("@Taikinjikan", txt_Taikinjikan.Text);
                    Command.Parameters.AddWithValue("@Kyukeijikan", txt_Kyukeijikan.Text);
                    Command.Parameters.AddWithValue("@gyomunaiyou", txt_gyomunaiyou.Text);
                    Command.Parameters.AddWithValue("@username", username);
                    Command.Parameters.AddWithValue("@Empid", EmpID);
                    Command.Connection.Open();
                    Command.ExecuteNonQuery();
                    Command.Connection.Close();
                    if (updateFlg)
                    {
                        MessageBox.Show("更新しました!");
                    }
                    else
                    {
                        MessageBox.Show("登録しました!");
                    }
                    this.Hide();
                    frm_tsukibetsurisuto fm = new frm_tsukibetsurisuto();
                    fm.Show();
                }
            }
        }