//リストダブルクリック private void m_customertantouList_DoubleClick(object sender, EventArgs e) { ListView.SelectedIndexCollection item = m_oper_List.SelectedIndices; opeDS opeDt = new opeDS(); opeDt.openo = this.m_oper_List.Items[item[0]].SubItems[0].Text; opeDt.opeid = this.m_oper_List.Items[item[0]].SubItems[1].Text; opeDt.lastname = this.m_oper_List.Items[item[0]].SubItems[2].Text; opeDt.fastname = this.m_oper_List.Items[item[0]].SubItems[3].Text; opeDt.password = this.m_oper_List.Items[item[0]].SubItems[4].Text; opeDt.biko = this.m_oper_List.Items[item[0]].SubItems[6].Text; opeDt.chk_date = this.m_oper_List.Items[item[0]].SubItems[7].Text; opeDt.chk_name_id = this.m_oper_List.Items[item[0]].SubItems[8].Text; string typetxt = this.m_oper_List.Items[item[0]].SubItems[5].Text; if (typetxt == "管理者") { opeDt.type = "1"; } else { opeDt.type = "2"; } ope_Disp(opeDt); //アドレスを表示 opeAddress(); }
//認証 正常:0 異常:-1 public int getOpeAuth(String userid, string pass, NpgsqlConnection conn) { NpgsqlCommand cmd; try { int ret = 0; if (conn.FullState != ConnectionState.Open) { conn.Open(); } String sql = @"SELECT openo,opeid,lastname,fastname,type FROM ope WHERE opeid = :opeid AND password=:pass "; cmd = new NpgsqlCommand(sql, conn); cmd.Parameters.Add(new NpgsqlParameter("opeid", DbType.String) { Value = m_opeid.Text }); cmd.Parameters.Add(new NpgsqlParameter("pass", DbType.String) { Value = m_pass.Text }); opeData = new opeDS(); int i = 0; var dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { opeData.openo = dataReader["openo"].ToString(); opeData.opeid = dataReader["opeid"].ToString(); opeData.lastname = dataReader["lastname"].ToString(); opeData.fastname = dataReader["fastname"].ToString(); opeData.type = dataReader["type"].ToString(); i++; } //取得できない場合はエラー if (i <= 0) { MessageBox.Show("ログインに失敗しました。", "ログイン", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); logger.InfoFormat("ログインに失敗しました: User -> {0}", m_opeid.Text); ret = -1; } else if (i > 0) { ret = 0; } return(ret); } catch (Exception ex) { MessageBox.Show("オペレータ情報の取得に失敗しました。" + ex.Message, "オペレータ情報取得", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.ErrorFormat("オペレータ情報の取得に失敗しました MSG: {0}: User -> {1}, pass -> {2}", ex.Message, m_opeid.Text, m_pass.Text); return(-1); } }
//オペレータの表示 private void ope_Disp(opeDS operDt) { m_openo.Text = operDt.openo; m_opeid.Text = operDt.opeid; m_lastname.Text = operDt.lastname; m_firstname.Text = operDt.fastname; m_password.Text = operDt.password; if (operDt.type == "1") { m_kengenCombo.Text = "管理者"; } else if (operDt.type == "2") { m_kengenCombo.Text = "利用者"; } m_biko.Text = operDt.biko; m_update.Text = operDt.chk_date; m_updateOpe.Text = operDt.chk_name_id; }