private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) { return; } Utility.ComboShain cmb = (Utility.ComboShain)comboBox1.SelectedItem; // データグリッドに表示されているか調べる int match = 0; for (int i = 0; i < dg1.Rows.Count; i++) { if (cmb.ID.ToString() == dg1[cID, i].Value.ToString() && cmb.code == dg1[cCode, i].Value.ToString()) { match = 1; break; } } if (match == 1) { MessageBox.Show("既に登録済みです", "パートタイマー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } lblNumber.Text = cmb.code; lblName.Text = cmb.Name; _SelectID = cmb.ID.ToString(); _BumonCode = cmb.BumonCode; _BumonName = cmb.BumonName; _Pt = cmb.code; }
private void btnUpdate_Click(object sender, EventArgs e) { DateTime StartDate; DateTime EndDate; int ShainID; try { if (comboBox1.SelectedIndex == -1) { MessageBox.Show("担当者を選択してください", MESSAGE_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (tDate.Checked == false) { StartDate = Convert.ToDateTime("1900/01/01"); } else { StartDate = Convert.ToDateTime(tDate.Value.ToShortDateString()); } if (tDate2.Checked == false) { EndDate = Convert.ToDateTime("9999/12/31"); } else { EndDate = Convert.ToDateTime(tDate2.Value.ToShortDateString()); } if (comboBox1.SelectedIndex == -1) { ShainID = 0; } else { Utility.ComboShain cmb1 = new Utility.ComboShain(); cmb1 = (Utility.ComboShain)comboBox1.SelectedItem; ShainID = cmb1.ID; } // グリッド表示 ShowDataLinq(dataGridView1, StartDate, EndDate, ShainID); if (dataGridView1.RowCount > 0) { btnPrn.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "選択", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// -------------------------------------------------------------------- /// <summary> /// 外注先データRowにデータセット </summary> /// <param name="r"> /// darwinDataSet.外注先Row </param> /// -------------------------------------------------------------------- private darwinDataSet.外注先Row dataRowSet(darwinDataSet.外注先Row r) { r.称 = txtName2.Text; r.フリガナ = txtFuri.Text; r.担当者名 = txtTantou.Text; r.担当部署 = txtBusho.Text; if (((mtxtZipCode.Text).Replace("-", "")).Trim() == "") { r.郵便番号 = ""; } else { r.郵便番号 = mtxtZipCode.Text; } r.住所1 = txtAddress1.Text; r.住所2 = txtAddress2.Text; r.電話番号 = txtTel.Text; r.FAX番号 = txtFax.Text; r.eMail = txtEmail.Text; Utility.ComboShain cmb1 = new Utility.ComboShain(); if (cmbShain.SelectedIndex == -1) { r.担当営業 = 0; } else { cmb1 = (Utility.ComboShain)cmbShain.SelectedItem; r.担当営業 = cmb1.ID; } r.備考 = txtMemo.Text; if (fMode.Mode == 0) { r.登録年月日 = DateTime.Now; } r.更新年月日 = DateTime.Now; r.ユーザーID = global.loginUserID; r.支払日 = Utility.strToInt(txtShiharaibi.Text); return(r); }
///----------------------------------------------------------- /// <summary> /// 個別印刷対象者情報をグリッドビューへ追加します </summary> ///----------------------------------------------------------- private void gridViewAdd() { // 社員未選択 if (comboBox1.SelectedIndex == -1) { MessageBox.Show("印刷する社員を選択して下さい", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); comboBox1.Focus(); return; } // 所属未選択 if (comboBox2.SelectedIndex == -1) { MessageBox.Show("所属を選択して下さい", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); comboBox2.Focus(); return; } // グリッドへ追加 dg1.Rows.Add(); dg1[0, dg1.Rows.Count - 1].Value = "True"; // 部門コンボ情報 Utility.ComboBumon cmbB = (Utility.ComboBumon)comboBox2.SelectedItem; dg1[1, dg1.Rows.Count - 1].Value = cmbB.code; dg1[2, dg1.Rows.Count - 1].Value = cmbB.Name; // 社員コンボ情報 Utility.ComboShain cmbS = (Utility.ComboShain)comboBox1.SelectedItem; dg1[3, dg1.Rows.Count - 1].Value = cmbS.code; dg1[4, dg1.Rows.Count - 1].Value = cmbS.Name; dg1[5, dg1.Rows.Count - 1].Value = ""; // コンボボックスクリア comboBox1.SelectedIndex = -1; comboBox1.Text = string.Empty; comboBox2.SelectedIndex = -1; comboBox2.Text = string.Empty; }
///---------------------------------------------------------------- /// <summary> /// 配列からコンボボックスにロードする </summary> /// <param name="tempObj"> /// コンボボックスオブジェクト</param> /// <param name="fName"> /// CSVデータファイルパス</param> /// <param name="cmbKbn"> /// 0:社員コンボボックス、1:部門コンボボックス</param> ///---------------------------------------------------------------- private static void arrayCmbLoad(ComboBox tempObj, Utility.xlsShain [] x, int cmbKbn) { string tl = ""; try { if (cmbKbn == global.flgOff) { tl = "社員"; } else { tl = "部門"; } Utility.ComboBumon cmb1; // 部門コンボボックス Utility.ComboShain cmbS; // 社員コンボボックス tempObj.Items.Clear(); tempObj.DisplayMember = "DisplayName"; tempObj.ValueMember = "code"; // 社員名簿配列読み込み System.Collections.ArrayList al = new System.Collections.ArrayList(); string bn = ""; foreach (var t in x) { if (cmbKbn == global.flgOff) { // 社員 bn = t.sCode.ToString().PadLeft(5, '0') + "," + t.sName + ""; } else { // 部門 bn = t.bCode.ToString().PadLeft(5, '0') + "," + t.bName + ""; } al.Add(bn); } // 配列をソートします al.Sort(); string alCode = string.Empty; foreach (var item in al) { string[] d = item.ToString().Split(','); // 重複はネグる if (alCode != string.Empty && alCode.Substring(0, 5) == d[0]) { continue; } // コンボボックスにセット if (cmbKbn == global.flgOn) { // 部門コンボボックス cmb1 = new Utility.ComboBumon(); cmb1.ID = 0; cmb1.DisplayName = item.ToString().Replace(',', ' '); string[] cn = item.ToString().Split(','); cmb1.Name = cn[1] + ""; cmb1.code = cn[0] + ""; tempObj.Items.Add(cmb1); } else if (cmbKbn == global.flgOff) { // 社員コンボボックス cmbS = new Utility.ComboShain(); cmbS.ID = 0; cmbS.DisplayName = item.ToString().Replace(',', ' '); string[] cn = item.ToString().Split(','); cmbS.Name = cn[1] + ""; cmbS.code = cn[0] + ""; tempObj.Items.Add(cmbS); } alCode = item.ToString(); } } catch (Exception ex) { MessageBox.Show(ex.Message, tl + "コンボボックスロード"); } }
/// ------------------------------------------------------------------ /// <summary> /// darwinDataSet.得意先Row行データ作成 </summary> /// <param name="r"> /// darwinDataSet.得意先Row オブジェクト</param> /// <returns> /// darwinDataSet.得意先Row オブジェクト</returns> /// ------------------------------------------------------------------ private darwinDataSet.得意先Row setClientRow(darwinDataSet.得意先Row r) { r.略称 = txtName1.Text; r.フリガナ = txtFuri.Text; r.称 = txtName2.Text; r.敬称 = cmbKeisho.Text; r.担当者名 = txtTantou.Text; r.部署名 = txtBusho.Text; if (((mtxtZipCode.Text).Replace("-", "")).Trim() == "") { r.郵便番号 = ""; } else { r.郵便番号 = mtxtZipCode.Text; } r.都道府県 = cmbCity.Text; r.住所1 = txtAddress1.Text; r.住所2 = txtAddress2.Text; r.電話番号 = txtTel.Text; r.FAX番号 = txtFax.Text; r.メールアドレス = txtEmail.Text; Utility.ComboShain cmb1 = new Utility.ComboShain(); if (cmbShain.SelectedIndex == -1) { r.担当社員コード = 0; } else { cmb1 = (Utility.ComboShain)cmbShain.SelectedItem; r.担当社員コード = cmb1.ID; } r.締日 = Int32.Parse(txtShimebi.Text); r.税通知 = cmbTax.Text.ToString(); if (((mtxtZipCodeS.Text).Replace("-", "")).Trim() == "") { r.請求先郵便番号 = ""; } else { r.請求先郵便番号 = mtxtZipCodeS.Text; } r.請求先都道府県 = cmbCityS.Text; r.請求先住所1 = txtAddress1S.Text; r.請求先住所2 = txtAddress2S.Text; r.請求先担当者名 = txtTantouS.Text; r.備考 = txtMemo.Text; if (fMode.Mode == 0) { r.登録年月日 = DateTime.Now; } r.更年月日 = DateTime.Now; r.請求先名称 = txtNameSeikyu.Text; // 2015/07/05 r.請求先部署名 = txtBushoS.Text; // 2019/02/20 r.請求先敬称 = cmbKeishoS.Text; // 2019/02/20 return(r); }