private void btnSearch_Click(object sender, EventArgs e) { string strID = txtID.Text.Trim(); string strName = txtName.Text.Trim(); string strCourse = txtCourse.Text.Trim(); string strDay = txtTimeOff.Text.Trim(); StringBuilder strSql = new StringBuilder(); //ArrayList listSql = new ArrayList(); if (strID.Length != 0) { strSql.Append(" where TID_ like '%" + strID + "%'"); } if (strName.Length != 0) { if (strSql.Length == 0) { strSql.Append(" where Tname_ like '%" + strName + "%'"); } else { strSql.Append(" and Tname_ like '%" + strName + "%'"); } } if (strDay.Length != 0) { if (strSql.Length == 0) { strSql.Append(" where timeoff like '%" + strDay + "%'"); } else { strSql.Append(" and timeoff like '%" + strDay + "%'"); } } if (strCourse.Length != 0) { if (strSql.Length == 0) { strSql.Append(" where course1_ like '%" + strCourse + "%' or " + strSql + "course2_ like '%" + strCourse + "%'"); } else { strSql.Append(" and course1_ like '%" + strCourse + "%' or " + strSql + " and course2_ like '%" + strCourse + "%'"); } } string str = "select *from Z_TMP_TeacherInfo" + strSql; DataTable dtUser = dao.GetDataTable(str); grdview.DataSource = dtUser; }
private void btnSearch_Click(object sender, EventArgs e) { StringBuilder strsql = new StringBuilder(); string strCID = txtCID.Text.Trim(); string strCNAME = txtCNAME.Text.Trim(); if (strCID.Length != 0) { strsql.Append(" where CID_ like '%" + strCID + "%'"); } if (strCNAME.Length != 0) { if (strsql.Length == 0) { strsql.Append(" where CName_ like '%" + strCNAME + "%'"); } else { strsql.Append(" and CName_ like '%" + strCNAME + "%'"); } } string strSql = "select *from z_tmp_CourseSum" + strsql + " order by Cid_"; dao.ExecuteScale(strSql); DataTable dtUser = dao.GetDataTable(strSql); grdView.DataSource = dtUser; }
private void query() { dbIntface dao = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd); //grdview.AutoGenerateColumns = false; string strsql = ("select * from z_tmp_COURSESUM order by CID_"); DataTable dtUser = dao.GetDataTable(strsql); grdView.DataSource = dtUser; }
private void SubTeacher_Load(object sender, EventArgs e) { string strsql = ("select * from z_tmp_COURSESUM order by CID_"); string strDay = ("select * from z_tmp_TimeOff"); string strClass = ("select * from z_tmp_Classinfo"); DataTable dt1 = dao.GetDataTable(strsql); DataTable dt2 = dao.GetDataTable(strsql); DataTable dt3 = dao.GetDataTable(strDay); DataTable dt4 = dao.GetDataTable(strClass); DataTable dt5 = dao.GetDataTable(strClass); CoBoxC1.DataSource = dt1; CoBoxC1.DisplayMember = "CName_"; CoBoxC1.ValueMember = "CID_"; CoBoxC2.DataSource = dt2; CoBoxC2.DisplayMember = "CName_"; CoBoxC2.ValueMember = "CID_"; CoBoxDay.DataSource = dt3; CoBoxDay.DisplayMember = "Day_"; CoBoxDay.ValueMember = "id_"; CoBoxCL1.DataSource = dt4; CoBoxCL1.DisplayMember = "ClassN_"; CoBoxCL1.ValueMember = "ClassN_"; CoBoxCL2.DataSource = dt5; CoBoxCL2.DisplayMember = "ClassN_"; CoBoxCL2.ValueMember = "ClassN_"; if (states == 1) { this.Text = "添加教师信息"; } if (states == 2) { this.Text = "修改教师信息"; lbID.Text = "编号:" + arr[0]; txtName.Text = arr[1]; CoBoxC1.Text = arr[2]; CoBoxC2.Text = arr[3]; CoBoxDay.Text = arr[4]; CoBoxCL1.Text = arr[5]; CoBoxCL2.Text = arr[6]; } }
private void btnQuery_Click(object sender, EventArgs e) { dbIntface dao = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd); string strSql = "select ID_, UNAME_, DEP_ ,COUNTRY_ ,PHONE_ ,REGDATE_ ,GENDER_ from z_tmp_user ORDER BY id_"; DataTable dtUser = dao.GetDataTable(strSql); grdView.DataSource = dtUser; }
private void btnSearch_Click(object sender, EventArgs e) { string strUserId = txtID.Text.Trim(); string strUserName = txtName.Text.Trim(); string strUserDep = txtDep.Text.Trim(); string strQue = ""; if (strUserId.Length > 0) { strQue = " where id_ like'%" + strUserId + "%'"; } if (strUserName.Length > 0) { if (strQue.Length == 0) { strQue = " where uname_ like '%" + strUserName + "%'"; } else { strQue += "and uname_ like '%" + strUserName + "%'"; } } if (strUserDep.Length > 0) { if (strQue.Length == 0) { strQue = " where DEP_='" + strUserDep + "'"; } else { strQue += "and DEP_='" + strUserDep + "'"; } } dbIntface dao = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd); string strSql = "select *from z_tmp_user" + strQue + " order by ID_"; DataTable dtUser = dao.GetDataTable(strSql); grdView.DataSource = dtUser; }
private void btnSubmit_Click(object sender, EventArgs e) { string strCName = txtCNAME.Text.Trim(); if (state == 1) { if (strCName.Length == 0) { MessageBox.Show("请输入课程名称"); } string strSql = "select CID_ from z_tmp_CourseSum"; DataTable dt = new DataTable(); dt = dao.GetDataTable(strSql); int[] arrayA = new int[dt.Rows.Count]; for (int x = 0; x < dt.Rows.Count; x++) { DataRow dr2 = dt.Rows[x]; arrayA[x] = Convert.ToInt16(dr2["CID_"]); } int strId = GetNextID(arrayA); int Cou = 0; string strsql = "insert into z_tmp_CourseSum (CID_,Cname_) values('" + strId + "','" + strCName + "')"; try { Cou = dao.ExecuteNonQuery(strsql); } catch (Exception ex) { log.Error(ex); } if (Cou > 0) { MessageBox.Show("保存成功!"); this.Close(); log.InfoFormat("添加用户{0}", strCName); } else { MessageBox.Show("保存失败!"); } } if (state == 2) { if (strCName.Length == 0) { MessageBox.Show("请输入课程名称"); } string sql = "update z_tmp_CourseSum set Cname_='" + strCName + "' where CID_='" + arr[0] + "'"; int cou = 0; try { cou = dao.ExecuteNonQuery(sql); } catch (Exception ex) { log.Error(ex); } if (cou > 0) { MessageBox.Show("保存成功!"); this.Close(); log.Debug("修改操作"); } else { MessageBox.Show("保存失败!"); } } }
private void btnSubmit_Click(object sender, EventArgs e) { string strUserName = txtName.Text.Trim(); string strUserDep = txtDep.Text.Trim(); string strUserPhone = txtPhone.Text.Trim(); string strUserCountry = txtCountry.Text.Trim(); string strGED = ""; if (status == 0) { if (strUserName.Length == 0) { MessageBox.Show("请输入姓名!"); txtName.Focus(); return; } if (strUserName.Length > 30) { MessageBox.Show("姓名过长!"); txtName.Focus(); return; } if (strUserDep.Length == 0) { MessageBox.Show("请输入部门!"); txtDep.Focus(); return; } if (strUserDep.Length > 30) { MessageBox.Show("部门名字过长!"); txtDep.Focus(); return; } if (strUserCountry.Length == 0) { MessageBox.Show("请输入国籍!"); txtCountry.Focus(); return; } if (strUserCountry.Length > 30) { MessageBox.Show("国家名字过长!"); txtCountry.Focus(); return; } if (strUserPhone.Length == 0) { MessageBox.Show("请输入手机号!"); txtPhone.Focus(); return; } if (strUserPhone.Length > 11) { MessageBox.Show("手机号非法"); txtPhone.Focus(); return; } if (comboBox1.SelectedIndex == 0) { strGED = "男"; } if (comboBox1.SelectedIndex == 1) { strGED = "女"; } if (strGED == "") { MessageBox.Show("请输入性别!"); return; } string StrRegTime = DateTime.Now.ToString("yyyy-MM-dd"); dbIntface dao = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd); string strSql1 = "alter session set nls_date_format = 'yyyy/mm/dd'"; //初始化日期格式 string strSql2 = "select ID_ from z_tmp_user"; DataTable dt = new DataTable(); dt = dao.GetDataTable(strSql2); string strSql3 = "insert into z_tmp_user(id_, uname_, dep_,country_,phone_,regdate_,gender_)values(seq_z_tmp_user.nextval,'" + strUserName + "', '" + strUserDep + "','" + strUserCountry + "','" + strUserPhone + "','" + StrRegTime + "','" + strGED + "')"; int nCou1 = 0; log.InfoFormat("添加新员工{0}", strUserName); try { dao.ExecuteNonQuery(strSql1); nCou1 = dao.ExecuteNonQuery(strSql3); } catch (Exception ex) { log.ErrorFormat("错误:{0}", ex.Message); } if (nCou1 > 0) { MessageBox.Show("保存成功!"); this.Close(); } else { MessageBox.Show("保存失败!"); } } if (status == 1) { if (comboBox1.SelectedIndex == 0) { strGED = "男"; } if (comboBox1.SelectedIndex == 1) { strGED = "女"; } dbIntface dao = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd); string strSql = "update z_tmp_user set uname_='" + strUserName + "',dep_='" + strUserDep + "', phone_='" + strUserPhone + "', country_='" + strUserCountry + "' ,gender_='" + strGED + "' where id_ = '" + arr[0] + "'"; int nCou = 0; log.Debug("修改操作"); try { nCou = dao.ExecuteNonQuery(strSql); } catch (Exception ex) { log.Error(ex); } if (nCou > 0) { MessageBox.Show("修改成功!"); } else { MessageBox.Show("修改失败!"); } } }