private void b_print_exclusion_Click(object sender, EventArgs e)
        {
            //印刷除外フラグを更新する。
            using (var db = new DB.DBConnect())
            {
                ;

                //オープン処理がないと怒られる。
                db.npg.Open();
                //StringBuilder sb = new StringBuilder();

                for (int i = 0; i < dataGridView1.RowCount; i++)
                {
                    string code      = (string)dataGridView1.Rows[i].Cells[1].Value;
                    bool   noprint   = (bool)dataGridView1.Rows[i].Cells[0].Value;
                    var    reception = db.t_reception.Single(x => x.reception_code == code);
                    if (noprint)
                    {
                        reception.noprint = "1";
                    }
                    else
                    {
                        reception.noprint = "0";
                    }

                    reception.update_date  = DateTime.Now;
                    reception.update_staff = MainForm.session_m_staff != null? MainForm.session_m_staff.staff_name:"";
                    db.SaveChanges();
                }
            }
        }
        //削除ボタン
        private void b_delete_Click(object sender, EventArgs e)
        {
            //予約テーブルに1件でもあれば、削除不可
            NpgsqlDataReader dataReader = null;
            using (var db = new DB.DBConnect())
            {
                //オープン処理がないと怒られる。
                db.npg.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append(@"select
                                *
                           ");
                sb.Append(@"from
                            t_reservation 
                            ");
                sb.Append(@" where reception_code = '@reception_code'".Replace("@reception_code", reception_code));
                var command = new NpgsqlCommand(sb.ToString(), db.npg);
                dataReader = command.ExecuteReader();
                if (dataReader.HasRows)
                {
                    MessageBox.Show("予約がすでに入ってますので、受付情報は削除できません。", "お知らせ", MessageBoxButtons.OK);
                    return;
                }
            }
            //削除
            using (var db = new DB.DBConnect())
            {
                //データ取得
                var receptions = db.t_reception;
                var data       = receptions.Single(x => x.reception_code == reception_code);
                //削除
                receptions.Remove(data);
                db.SaveChanges();

                MessageBox.Show("受付情報を削除しました。", "お知らせ", MessageBoxButtons.OK);
            }

            //セッション情報の削除
            if (MainForm.session_t_reception != null)
            {
                MainForm.session_t_reception = null;
            }
            MainForm.Header_Menu.LabelReWrite();

            //一つ前のボタンに戻る。
            pageParent.PageRefresh();
            MainForm.backPage(this);
        }
Ejemplo n.º 3
0
        //登録
        private void b_regist_Click(object sender, EventArgs e)
        {
            //入力チェック
            chk.clear();
            chk.addControl(d_tenpo);
            chk.addControl(t_staff_code);
            chk.addControl(t_staff);
            chk.addControl(t_staff_kana);
            chk.addControl(t_login_id);
            chk.addControl(t_password);
            chk.addControl(d_kengen);
            chk.addControl(d_employment);
            chk.addControl(d_seibetsu);
            chk.addControl(d_status);
            if (chk.check("W00000", chk.checkControlImportant))
            {
                return;
            }

            //桁数チェック
            chk.clear();
            chk.addControl(t_staff_code);
            if (chk.check("W00001", chk.checkTextboxLength, 8))
            {
                return;
            }

            chk.clear();
            chk.addControl(t_login_id);
            chk.addControl(t_staff);
            if (chk.check("W00001", chk.checkTextboxLength, 20))
            {
                return;
            }

            chk.clear();
            chk.addControl(t_staff_kana);
            if (chk.check("W00001", chk.checkTextboxLength, 40))
            {
                return;
            }

            chk.clear();
            chk.addControl(t_password);
            if (chk.check("W00001", chk.checkTextboxLength, 256))
            {
                return;
            }

            //データベース更新処理
            //データの取得
            StaffListStore();

            if (update_flag == false || newData_flag == true)
            {
                // 接続インスタンスを作成。
                var dbc = new DB.DBConnect();


                // 登録する新規データの入れ物を作成(スタッフマスターに対して実行する)。
                DB.m_staff data = dbc.m_staff.Create();
                //データの投入
                data.store_code       = staff_store_code;
                data.staff_code       = staff_code;
                data.staff_name       = staff_name;
                data.staff_name_kana  = staff_name_kana;
                data.login_id         = staff_login_id;
                data.password         = staff_Hash_password;
                data.permission_class = staff_kengen;
                data.work_class       = staff_employment;
                data.status           = staff_status;
                data.sex = staff_seibetu;


                data.registration_date  = staff_registration_date;
                data.registration_staff = staff_registration_staff;
                data.update_date        = staff_update_date;
                data.update_staff       = staff_update_staff;
                data.delete_flag        = staff_delete_flag;


                // レコードををテーブルに登録。
                dbc.m_staff.Add(data);

                try
                {
                    dbc.SaveChanges();
                }
                catch (Exception)
                {
                    Utile.Message.showMessageOK("E14000");
                    return;
                }
                finally
                {
                    dbc.npg.Close();
                }
            }
            else if (update_flag == true || newData_flag == false)
            {
                // 接続インスタンスを作成。
                var dbc2 = new DB.DBConnect();
                //更新用スタッフコードの取得
                index           = currentPage - 1;
                updateStaffCode = StaffDBList[index].staff_code;
                //更新前データの取り込み
                var filterData = StaffDBList[index];
                storeIndex = this.d_tenpo.SelectedIndex;


                //更新前データの取り込み
                m_StaffStaff_store_code         = filterData.staff_store_code;
                m_StaffStaff_code               = filterData.staff_code;
                m_StaffStaff_name               = filterData.staff_name;
                m_StaffStaff_name_kana          = filterData.staff_name_kana;
                m_StaffStaff_login_id           = filterData.login_id;
                m_StaffStaff_password           = filterData.password;
                m_StaffStaff_kengen             = filterData.kengen;
                m_StaffStaff_status             = filterData.status;
                m_StaffStaff_employment         = filterData.employment;
                m_StaffStaff_seibetu            = filterData.seibetu;
                m_StaffStaff_registration_date  = filterData.registration_date;
                m_StaffStaff_registration_staff = filterData.registration_staff;
                m_StaffStaff_update_date        = filterData.update_date;
                m_StaffStaff_update_staff       = filterData.update_staff;
                m_StaffStaff_delete_flag        = filterData.delete_flag;

                //更新用スタッフコードの取得
                index           = currentPage - 1;
                updateStaffCode = StaffDBList[index].staff_code;
                storeIndex      = this.d_tenpo.SelectedIndex;
                updateStoreCode = storeCodeList[storeIndex].store_code;
                // 接続インスタンスを作成。
                var dbc = new DB.DBConnect();
                dbc.npg.Open();
                StringBuilder sb = new StringBuilder();
                using (var transaction = dbc.npg.BeginTransaction())
                {
                    sb.Append("update m_staff set ");
                    if (staff_store_code != m_StaffStaff_store_code)
                    {
                        sb.Append("store_code = '" + staff_store_code + "', ");
                    }
                    if (staff_code != m_StaffStaff_code)
                    {
                        sb.Append("staff_code = '" + staff_code + "', ");
                    }
                    if (staff_name != m_StaffStaff_name)
                    {
                        sb.Append("staff_name = '" + staff_name + "', ");
                    }
                    if (staff_name_kana != m_StaffStaff_name_kana)
                    {
                        sb.Append("staff_name_kana = '" + staff_name_kana + "', ");
                    }
                    if (staff_login_id != m_StaffStaff_login_id)
                    {
                        sb.Append("login_id = '" + staff_login_id + "', ");
                    }
                    if (staff_Hash_password != m_StaffStaff_password)
                    {
                        sb.Append("password = '******', ");
                    }
                    if (staff_kengen != m_StaffStaff_kengen)
                    {
                        sb.Append("permission_class = '" + staff_kengen + "', ");
                    }
                    if (staff_employment != m_StaffStaff_employment)
                    {
                        sb.Append("work_class = '" + staff_employment + "', ");
                    }
                    if (staff_status != m_StaffStaff_status)
                    {
                        sb.Append("status = '" + staff_status + "', ");
                    }
                    if (staff_seibetu != m_StaffStaff_seibetu)
                    {
                        sb.Append("sex = '" + staff_seibetu + "', ");
                    }
                    sb.Append("update_date = '" + nowToday + "', ");
                    sb.Append("update_staff = '" + MainForm.session_m_staff.staff_name + "', ");
                    sb.Append("delete_flag = '" + staff_delete_flag + "' ");
                    sb.Append("where store_code = '" + staff_store_code + "' AND ");
                    sb.Append("staff_code = '" + staff_code + "';");

                    string strsql = sb.ToString();

                    var command = new NpgsqlCommand(strsql, dbc.npg);
                    try
                    {
                        command.ExecuteNonQuery();
                        transaction.Commit();
                    }
                    catch (NpgsqlException)
                    {
                        transaction.Rollback();
                        Utile.Message.showMessageOK("E14001");
                        return;
                    }
                    finally
                    {
                        dbc.npg.Close();
                    }
                }
            }

            //登録後画面初期化し次の登録を始める
            MainForm.Staff_master.PageRefresh();
            //MainForm.backPage(this);
            if (data_flag == false && update_flag == false)
            {
                currentPage++;
                totalPage++;
            }
            else if (data_flag == true && update_flag == false)
            {
                currentPage = StaffDBList.Count + 1;
                totalPage   = StaffDBList.Count + 1;
            }
            else if (data_flag == true && update_flag == true)
            {
                currentPage = StaffDBList.Count;
                totalPage   = StaffDBList.Count;
            }
            //新規データフラグを立てる
            newData_flag = true;
            //データ取得
            ListArrayStaff();
            init_flag   = false;
            update_flag = false;
            Set_initialDisplay();
            t_current_page.Text = (string)currentPage.ToString("0");
            t_total_page.Text   = (string)totalPage.ToString("0");

            pageParent.PageRefresh();
            MainForm.backPage(this);
        }
Ejemplo n.º 4
0
        private void b_regist_Click(object sender, EventArgs e)
        {
            //必須入力チェック
            //存在チェック項目の追加
            chkExist.addControl(t_reception_code);
            chkExist.addControl(d_receipt_date);
            chkExist.addControl(t_reception_time);
            chkExist.addControl(d_receipt_staff);
            chkExist.addControl(d_receipt_store);
            chkExist.addControl(d_status);
            chkExist.addControl(t_photographers);
            chkExist.addControl(d_coming_store_category);
            chkExist.addControl(d_motivation);
            chkExist.addControl(d_customer_code);
            if (chkExist.check("W00000", chkExist.checkControlImportant))
            {
                return;
            }

            //受付コードチェック
            chkreceptcode.addControl(t_reception_code);
            if (chkreceptcode.check("W00001", chkreceptcode.checkTextboxLength, 8))
            {
                return;
            }

            //受付時間チェック
            chkrecepttime.addControl(t_reception_time);
            if (chkrecepttime.check("W00001", chkrecepttime.checkTextboxLength, 5))
            {
                return;
            }
            if (chkrecepttime.check("W00003", chkrecepttime.checkTextboxFormat, @"^[0-2][0-9]:[0-5][0-9]$", @"HH:MM"))
            {
                return;
            }

            //撮影人数チェック
            chkphotographers.addControl(t_photographers);
            if (chkphotographers.check("W00001", chkphotographers.checkTextboxLength, 4))
            {
                return;
            }

            if (chkphotographers.check("W00003", chkphotographers.checkTextboxFormat, @"\d+", @"0~9999"))
            {
                return;
            }

            //メモチェック
            //メモチェック
            chkmemo.addControl(t_memo);
            if (chkmemo.check("W00001", chkmemo.checkTextboxLength, 255))
            {
                return;
            }

            //クレームチェック
            //クレームチェック
            chkclaim.addControl(d_claim);
            if (chkclaim.check("W00001", chkclaim.checkTextboxLength, 255))
            {
                return;
            }


            //登録処理
            //キーの設定
            string recept_code = t_reception_code.Text;

            //登録処理
            DB.t_reception reception = new DB.t_reception();
            using (var dbc = new DB.DBConnect())
            {
                dbc.npg.Open();
                using (var transaction = dbc.npg.BeginTransaction())
                {
                    //登録処理
                    var data = dbc.t_reception.FirstOrDefault(x => x.reception_code == recept_code);
                    if (data == null)
                    {
                        reception.reception_code        = recept_code;
                        reception.receipt_date          = d_receipt_date.Value;
                        reception.receipt_time          = TimeSpan.Parse(t_reception_time.Text);
                        reception.status                = (d_status.SelectedIndex + 1).ToString();
                        reception.photographers         = int.Parse(t_photographers.Text);
                        reception.coming_store_category = (d_coming_store_category.SelectedIndex + 1).ToString();
                        reception.customer_code         = d_customer_code.Text != ""? d_customer_code.Text:"00000000";
                        reception.store              = storeCodeList.Find(x => x.store_name == d_receipt_store.Text).store_name;
                        reception.staff              = staffCodeList.Find(x => x.staff_name == d_receipt_staff.Text).staff_name;
                        reception.memo               = t_memo.Text;
                        reception.claim              = d_claim.Text;
                        reception.motivation         = (d_motivation.SelectedIndex + 1).ToString();
                        reception.noprint            = "0";
                        reception.registration_date  = DateTime.Now.Date;
                        reception.registration_staff = MainForm.session_m_staff.staff_name;
                        dbc.t_reception.Add(reception);
                    }
                    else
                    {
                        MessageBox.Show("データがすでに存在してます。");
                        return;
                    }
                    try
                    {
                        dbc.SaveChanges();
                        transaction.Commit();
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                    }
                }
            }
            if (d_customer_code.Text != "")
            {
                //セッション情報の追加
                MainForm.session_t_reception = reception;

                //ヘッダメニュー更新
                MainForm.Header_Menu.LabelReWrite();
            }

            //一つ前に戻る
            pageParent.PageRefresh();
            MainForm.backPage(this);
        }
Ejemplo n.º 5
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            chk.clear();

            //必須入力チェック(スタッフが選択時、他の項目がブランクの場合はエラー)
            // 必須チェック
            chk.addControl(co_store);
            if (chk.check("W00000", chk.checkControlImportant))
            {
                return;
            }

            for (var i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells["Staff"].Value == null  ||
                    dataGridView1.Rows[i].Cells["Staff"].Value.ToString() == "")
                {
                    break;
                }

                if (dataGridView1.Rows[i].Cells["StartTime"].Value == null ||
                    dataGridView1.Rows[i].Cells["EndTime"].Value == null ||
                    dataGridView1.Rows[i].Cells["WorkClass"].Value == null)
                {
                    dataGridView1.Rows[i].Selected = true;
                    Utile.Message.showMessageOK("E11005");
                    return;
                }
            }


            //フォーマットチェック(日付: HH: MM) HH:0~23MM:0~59
            for (var i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells["Staff"].Value == null ||
                    dataGridView1.Rows[i].Cells["Staff"].Value.ToString() == "")
                {
                    break;
                }

                if (!System.Text.RegularExpressions.Regex.IsMatch(
                        dataGridView1.Rows[i].Cells["StartTime"].Value.ToString(),
                        @"\A[0-2][0-9]:[0-5][0-9]\z"))
                {
                    dataGridView1.Rows[i].Selected = true;
                    var msg = Utile.Message.message["W00003"].Replace("@フォーマット",
                                                                      dataGridView1.Rows[i].Cells["StartTime"].Value.ToString());
                    Utile.Message.showMessageOK("W00003", msg);

                    return;
                }

                if (!System.Text.RegularExpressions.Regex.IsMatch(
                        dataGridView1.Rows[i].Cells["EndTime"].Value.ToString(),
                        @"\A[0-2][0-9]:[0-5][0-9]\z"))
                {
                    dataGridView1.Rows[i].Selected = true;
                    var msg = Utile.Message.message["W00003"].Replace("@フォーマット",
                                                                      dataGridView1.Rows[i].Cells["EndTime"].Value.ToString());
                    Utile.Message.showMessageOK("W00003", msg);
                    return;
                }
            }

            //開始時間 < 終了時間をチェック
            for (var i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells["Staff"].Value == null ||
                    dataGridView1.Rows[i].Cells["Staff"].Value.ToString() == "")
                {
                    break;
                }

                if (dataGridView1.Rows[i].Cells["WorkClass"].Value.ToString() == "2")
                {
                    break;
                }

                var StartTime = int.Parse(dataGridView1.Rows[i].Cells["StartTime"].Value.ToString().Substring(0, 2) +
                                          dataGridView1.Rows[i].Cells["StartTime"].Value.ToString().Substring(3, 2));
                var EndTime = int.Parse(dataGridView1.Rows[i].Cells["EndTime"].Value.ToString().Substring(0, 2) +
                                        dataGridView1.Rows[i].Cells["EndTime"].Value.ToString().Substring(3, 2));

                if (dataGridView1.Rows[i].Cells[1].Value == null)
                {
                    break;
                }

                if (StartTime > 2359)
                {
                    dataGridView1.Rows[i].Selected = true;
                    Utile.Message.showMessageOK("E11003");
                    return;
                }
                if (EndTime > 2359)
                {
                    dataGridView1.Rows[i].Selected = true;
                    Utile.Message.showMessageOK("E11003");
                    return;
                }


                if (StartTime >= EndTime)
                {
                    dataGridView1.Rows[i].Selected = true;
                    Utile.Message.showMessageOK("E11002");
                    return;
                }
            }
            //DB処理
            using (var dbc = new DB.DBConnect())
            {
                dbc.npg.Open();
                using (var transaction = dbc.npg.BeginTransaction())
                {
                    try
                    {
                        //削除処理
                        var staff_shift = dbc.m_staff_shift;
                        //var delete_data = dbc.m_staff_shift.Where(x => x.work_day == l_calenderdata && x.store_code==l_store).Select(x=>x.work_day);

                        var delete_data = from ss in dbc.m_staff_shift
                                          where ss.work_day == l_calenderdata & ss.store_code == l_store
                                          select ss;
                        foreach (var data in delete_data)
                        {
                            dbc.m_staff_shift.Remove(data);
                        }

                        dbc.SaveChanges();

                        //登録処理
                        for (var i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            if (dataGridView1.Rows[i].Cells["Staff"].Value == null ||
                                dataGridView1.Rows[i].Cells["Staff"].Value.ToString() == "")
                            {
                                break;
                            }

                            DB.m_staff_shift staff_Shift = new DB.m_staff_shift();

                            var l_staff_code  = dataGridView1.Rows[i].Cells["StaffCode"].Value.ToString();
                            var register_data = staff_shift.FirstOrDefault(x => x.work_day == l_calenderdata &&
                                                                           x.store_code == l_store &&
                                                                           x.staff_code == l_staff_code);
                            if (register_data == null)
                            {
                                staff_Shift.work_day           = l_calenderdata;
                                staff_Shift.store_code         = l_store;
                                staff_Shift.staff_code         = l_staff_code;
                                staff_Shift.start_time         = TimeSpan.Parse(dataGridView1.Rows[i].Cells["StartTime"].Value.ToString());
                                staff_Shift.end_time           = TimeSpan.Parse(dataGridView1.Rows[i].Cells["EndTime"].Value.ToString());
                                staff_Shift.registration_date  = DateTime.Now.Date;
                                staff_Shift.registration_staff = MainForm.session_m_staff.staff_name;
                                staff_Shift.update_date        = DateTime.Now.Date;
                                staff_Shift.work_class         = dataGridView1.Rows[i].Cells["WorkClass"].Value.ToString();
                                staff_Shift.update_staff       = MainForm.session_m_staff.staff_name;
                                staff_Shift.delete_flag        = "0";
                                dbc.m_staff_shift.Add(staff_Shift);
                                dbc.SaveChanges();
                            }
                            else
                            {
                                Utile.Message.showMessageOK("E11004");
                                transaction.Rollback();
                                return;
                            }
                        }

                        transaction.Commit();
                    }
                    catch (SqlCeException)
                    {
                        Utile.Message.showMessageOK("E11006");
                        transaction.Rollback();
                    }
                }
            }
            //ひとつ前の画面に戻る
            SelfViewing = false;
            pageParent.PageRefresh();
            MainForm.backPage(this);
        }
Ejemplo n.º 6
0
        private void b_regist_Click(object sender, EventArgs e)
        {
            //登録処理
            //日付の特定
            List <DateTime> dates    = new List <DateTime>();
            var             interval = int.Parse(n_kankaku.Value.ToString());
            var             enddate  = d_syuryoubi.Text.ToString() != "" ? DateTime.Parse(d_syuryoubi.Text.ToString()) : DateTime.MaxValue;

            //繰り返し方法により分岐
            if (d_kurikaeshi.Text == "なし")
            {
                dates.Add(monthCalendar1.SelectionStart);
            }
            else if (d_kurikaeshi.Text == "毎週")
            {
                List <int> week = new List <int>();


                if (c_monday.Checked == true)
                {
                    week.Add(1);
                }
                if (c_tuseday.Checked == true)
                {
                    week.Add(2);
                }
                if (c_wednesday.Checked == true)
                {
                    week.Add(3);
                }
                if (c_thursday.Checked == true)
                {
                    week.Add(4);
                }
                if (c_friday.Checked == true)
                {
                    week.Add(5);
                }
                if (c_saturday.Checked == true)
                {
                    week.Add(6);
                }
                if (c_sunday.Checked == true)
                {
                    week.Add(0);
                }
                //日付指定、回数指定
                if (r_kai.Checked == true && t_kaisu.ToString() != "")
                {
                    int.TryParse(t_kaisu.Text.ToString(), out int count);
                    dates = GetWeeks(DateTime.Parse(d_kaishibi.Text), count, week, interval);
                }
                else
                {
                    dates = GetWeeks(DateTime.Parse(d_kaishibi.Text), enddate, week, interval);
                }
            }
            else if (d_kurikaeshi.Text == "毎月")
            {
                //日付指定、回数指定
                if (r_kai.Checked == true && t_kaisu.ToString() != "")
                {
                    int.TryParse(t_kaisu.Text.ToString(), out int count);
                    dates = GetDays(DateTime.Parse(d_kaishibi.Text), count, interval);
                }
                else
                {
                    dates = GetDays(DateTime.Parse(d_kaishibi.Text), enddate, interval);
                }
            }

            var storecode = storeCodeList.Find(x => x.store_name == d_tenpo.Text.ToString()).store_code;

            foreach (DateTime d in dates)
            {
                DB.t_calendar_information calendar_Information = new DB.t_calendar_information();
                using (var dbc = new DB.DBConnect())
                {
                    dbc.npg.Open();
                    using (var transaction = dbc.npg.BeginTransaction())
                    {
                        var holiday_class = d_kyujitsukubun.Text.ToString() == "営業日" ? (int)Utile.Data.休日区分.営業日 :
                                            d_kyujitsukubun.Text.ToString() == "定休日" ?
                                            (int)Utile.Data.休日区分.定休日 : (int)Utile.Data.休日区分.臨時休業;


                        //登録処理
                        var data = dbc.t_calendar_information.FirstOrDefault(x => x.store_code == storecode & x.date == d.Date);

                        if (data == null)
                        {
                            //新規登録
                            calendar_Information.store_code         = storecode;
                            calendar_Information.date               = d.Date;
                            calendar_Information.notice             = t_oshirashe.Text.ToString();
                            calendar_Information.holiday_class      = holiday_class.ToString();
                            calendar_Information.registration_date  = DateTime.Now.Date;
                            calendar_Information.registration_staff = MainForm.session_m_staff.staff_name;

                            dbc.t_calendar_information.Add(calendar_Information);
                        }
                        else
                        {
                            //更新情報
                            data.notice        = t_oshirashe.Text.ToString();
                            data.store_code    = storecode;
                            data.holiday_class = holiday_class.ToString();
                            data.update_date   = DateTime.Now.Date;
                            data.update_staff  = MainForm.session_m_staff.staff_name;
                        }

                        try
                        {
                            dbc.SaveChanges();
                            transaction.Commit();
                        }
                        catch (Exception)
                        {
                            transaction.Rollback();
                            throw;
                        }
                    }
                }
            }

            //ひとつ前に戻る
            MainForm.Store_calender.PageRefresh();
            MainForm.backPage(this);
        }