// //ページの初期化(新規追加) // public override void PageRefresh() { customer = new DB.m_customer(); member = new DB.m_member(); familyList = new List <DB.m_family>(); //Comboboxの設定 co_Sex.DataSource = Enum.GetValues(typeof(Utile.Data.性別)); co_Visit_motive.DataSource = Enum.GetValues(typeof(Utile.Data.来店動機)); co_Registered_store.DataSource = DB.m_store.getStoreNameList(); co_Rank.DataSource = Enum.GetValues(typeof(Utile.Data.ランク)); co_Membership_type.DataSource = Enum.GetValues(typeof(Utile.Data.会員種別)); //データを設定 t_Pref_city_town_village_name.Text = ""; t_Address2.Text = ""; t_Apartment_mansion.Text = ""; da_Birthday.Value = DateTime.Now.Date; t_Customer_code.Text = ""; ch_DM_Available.Checked = false; t_Fax.Text = ""; t_Free_item1.Text = ""; t_Free_item2.Text = ""; t_Free_item3.Text = ""; t_mail.Text = ""; t_name.Text = ""; t_name_kana.Text = ""; t_Phone_number1.Text = ""; t_Phone_number2.Text = ""; t_Phone_number3.Text = ""; t_Postal_code.Text = ""; co_Visit_motive.SelectedIndex = 0; t_Remark.Text = ""; ch_Sample.Checked = false; co_Sex.SelectedIndex = 0; t_surname.Text = ""; t_surname_kana.Text = ""; da_Customer_wedding_anniversary.Value = DateTime.Now.Date; da_Registration_date.Value = da_Registration_date.MinDate; co_Membership_type.SelectedIndex = 0; co_Rank.SelectedIndex = 0; t_Registration_officer.Text = ""; co_Registered_store.SelectedIndex = 0; dataGridView1.Rows.Clear(); //変更チェックリセット mod.reset(); //入力チェックリセット chk.clear(); //一覧クリア dataGridView2.Rows.Clear(); dataGridView4.Rows.Clear(); listView1.Items.Clear(); }
private void touroku_Click(object sender, EventArgs e) { //新規登録時の重複チェック if (mod.controlCloneList[t_Customer_code.Name].ToString() == "") { using (var dbc = new DB.DBConnect()) { // var q = from t in dbc.t_facility_reservation // where t.facility_reservation_code.Trim() == t_Customer_code.Text var q = from t in dbc.m_customer where t.customer_code == t_Customer_code.Text select t; //登録済みコードかチェック if (q.ToList().Count != 0) { if (Utile.Message.showMessageOKCancel("W09007") == DialogResult.Cancel) { return; } } } } //入力チェック chk.clear(); // 必須チェック chk.addControl(t_Customer_code); chk.addControl(t_name); chk.addControl(t_name_kana); chk.addControl(da_Birthday); chk.addControl(t_Postal_code); chk.addControl(t_Pref_city_town_village_name); chk.addControl(t_Address2); chk.addControl(t_surname); chk.addControl(t_surname_kana); if (chk.check("W00000", chk.checkControlImportant)) { return; } chk.clear(); // フォーマットチェック // 電話番号 chk.addControl(t_Phone_number1); chk.addControl(t_Phone_number2); chk.addControl(t_Phone_number3); chk.addControl(t_Fax); if (chk.check("W00003", chk.checkTextboxFormat, @"\A0\d{1,4}-\d{1,4}-\d{4}\z", "000-0000-0000")) { return; } chk.clear(); // メールアドレス chk.addControl(t_mail); if (chk.check("W00003", chk.checkTextboxFormat, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", "*****@*****.**")) { return; } chk.clear(); // 郵便番号 chk.addControl(t_Postal_code); if (chk.check("W00003", chk.checkTextboxFormat, @"\A\d\d\d-\d\d\d\d\z", "000-0000")) { return; } chk.clear(); // 桁数チェック // 8 chk.addControl(t_Customer_code); chk.addControl(t_Postal_code); if (chk.check("W00001", chk.checkTextboxLength, 8)) { return; } chk.clear(); // 10 chk.addControl(t_name); chk.addControl(t_surname); if (chk.check("W00001", chk.checkTextboxLength, 10)) { return; } chk.clear(); // 13 chk.addControl(t_Phone_number1); chk.addControl(t_Phone_number2); chk.addControl(t_Phone_number3); chk.addControl(t_Fax); if (chk.check("W00001", chk.checkTextboxLength, 13)) { return; } chk.clear(); // 20 chk.addControl(t_name_kana); chk.addControl(t_surname_kana); if (chk.check("W00001", chk.checkTextboxLength, 20)) { return; } chk.clear(); // 60 chk.addControl(t_Pref_city_town_village_name); chk.addControl(t_Address2); chk.addControl(t_Apartment_mansion); chk.addControl(t_Free_item1); chk.addControl(t_Free_item2); chk.addControl(t_Free_item3); if (chk.check("W00001", chk.checkTextboxLength, 60)) { return; } chk.clear(); // 255 chk.addControl(t_mail); chk.addControl(t_Remark); if (chk.check("W00001", chk.checkTextboxLength, 225)) { return; } chk.clear(); //変数に挿入 address1 = customer.address1 = t_Pref_city_town_village_name.Text; address2 = customer.address2 = t_Address2.Text; address3 = customer.address3 = t_Apartment_mansion.Text; birthday = customer.birthday = da_Birthday.Value; customer_code = customer.customer_code = t_Customer_code.Text; customer.dm_delivery = (ch_DM_Available.Checked ? (int)Utile.Data.DM送付区分.送付可 : (int)Utile.Data.DM送付区分.送付不可).ToString(); customer.fax_number = t_Fax.Text; customer.free_item1 = t_Free_item1.Text; customer.free_item2 = t_Free_item2.Text; customer.free_item3 = t_Free_item3.Text; mail_address = customer.mail_address = t_mail.Text; name = customer.name = t_name.Text; customer.name_kana = t_name_kana.Text; phone_number1 = customer.phone_number1 = t_Phone_number1.Text; phone_number2 = customer.phone_number2 = t_Phone_number2.Text; phone_number3 = customer.phone_number3 = t_Phone_number3.Text; postal_code = customer.postal_code = t_Postal_code.Text; customer.reasons = co_Visit_motive.SelectedItem.ToString(); customer.remarks = t_Remark.Text; customer.sample_availability = (ch_Sample.Checked ? (int)Utile.Data.サンプル可否.送付可 : (int)Utile.Data.サンプル可否.送付不可).ToString(); sex = customer.sex = (co_Sex.SelectedIndex == (int)Utile.Data.性別.女 ? (int)Utile.Data.性別.女 : (int)Utile.Data.性別.男).ToString(); surname = customer.surname = t_surname.Text; customer.surname_kana = t_surname_kana.Text; customer.wedding_anniversary = da_Customer_wedding_anniversary.Value; if (da_Registration_date.Value != da_Registration_date.MinDate) { member = new DB.m_member(); member.customer_code = t_Customer_code.Text; member.date = da_Registration_date.Value; member.membership_type = co_Membership_type.SelectedIndex.ToString(); member.rank = co_Rank.SelectedIndex.ToString(); member.staff = MainForm.session_m_staff.staff_name; member.store = DB.m_store.getSingle(MainForm.session_m_staff.store_code).store_name; } foreach (var family in familyList) { family.Command(delete: true); } familyList.Clear(); foreach (var family in dataGridView1.Rows.Cast <DataGridViewRow>()) { if (family.Cells["続柄"].Value == null && family.Cells["姓"].Value == null && family.Cells["姓カナ"].Value == null && family.Cells["名"].Value == null && family.Cells["名カナ"].Value == null && family.Cells["誕生日"].Value == null && family.Cells["性別"].Value == null && family.Cells["備考"].Value == null) { continue; } DB.m_family data = new DB.m_family(); data.customer_code = t_Customer_code.Text; data.branch_number = family.Index; if (family.Cells["続柄"].Value != null) { data.relationship = family.Cells["続柄"].Value.ToString(); } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["姓"].Value != null) { data.surname = family.Cells["姓"].Value.ToString(); } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["姓カナ"].Value != null) { data.surname_kana = family.Cells["姓カナ"].Value.ToString(); } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["名"].Value != null) { data.name = family.Cells["名"].Value.ToString(); } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["名カナ"].Value != null) { data.name_kana = family.Cells["名カナ"].Value.ToString(); } else { Utile.Message.showMessageOK("I09003"); return; } DateTime tmp = DateTime.MinValue; if (family.Cells["誕生日"].Value != null) { if (DateTime.TryParse(family.Cells["誕生日"].Value.ToString(), out tmp)) { data.birthday = tmp; } else { Utile.Message.showMessageOK("I09004"); return; } } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["性別"].Value != null) { if (Utile.Data.性別.女.ToString() == family.Cells["性別"].Value.ToString() || Utile.Data.性別.男.ToString() == family.Cells["性別"].Value.ToString()) { data.sex = (family.Cells["性別"].Value.ToString() == Utile.Data.性別.女.ToString() ? (int)Utile.Data.性別.女 : (int)Utile.Data.性別.男).ToString(); } else { Utile.Message.showMessageOK("I09005"); return; } } else { Utile.Message.showMessageOK("I09003"); return; } if (family.Cells["備考"].Value != null) { data.remarks = family.Cells["備考"].Value.ToString(); } else { data.remarks = null; } familyList.Add(data); } customer.Command(); if (da_Registration_date.Value != da_Registration_date.MinDate) { member.Command(); } foreach (var family in familyList) { family.Command(); } //変更チェックリセット mod.reset(); Utile.Message.showMessageOK("I09001"); }