Ejemplo n.º 1
0
        private void btnDelet_Click(object sender, EventArgs e)
        {
            if (grdView.DataSource == null)
            {
                MessageBox.Show("请先选中数据");
            }
            else
            {
                string Confirm = string.Format("确认删除编号{0},{1}?", grdView[0, grdView.SelectedCells[0].RowIndex].Value.ToString(), grdView[1, grdView.SelectedCells[1].RowIndex].Value.ToString());

                DialogResult dr = MessageBox.Show(Confirm, "确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dr == DialogResult.OK)
                {
                    string    id_;
                    string    name;
                    int       index = 0;
                    string    tmp   = "delete from z_tmp_user where id_='" + grdView[index, grdView.SelectedCells[0].RowIndex].Value.ToString() + "'";
                    dbIntface dao   = dbFactory.GetDataBase(ComClass.m_DB_Source, ComClass.m_DB_User, ComClass.m_DB_Pwd);
                    dao.ExecuteNonQuery(tmp);
                    id_  = grdView[0, grdView.SelectedCells[0].RowIndex].Value.ToString();
                    name = grdView[1, grdView.SelectedCells[1].RowIndex].Value.ToString();
                    log.InfoFormat("删除:编号{0},姓名{1}", id_, name);
                }
            }
            btnQuery_Click(null, null);
        }
Ejemplo n.º 2
0
        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("保存失败!");
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string strName = txtName.Text.Trim();
            string strC1   = CoBoxC1.Text.Trim();
            string strC2   = CoBoxC2.Text.Trim();
            string strDay  = CoBoxDay.Text.Trim();
            string strCL1  = CoBoxCL1.Text.Trim();
            string strCL2  = CoBoxCL2.Text.Trim();

            if (states == 1)
            {
                if (strName.Length == 0)
                {
                    MessageBox.Show("请输入姓名");
                    return;
                }
                if (strC1.Length == 0)
                {
                    MessageBox.Show("请选择负责课程一");
                    return;
                }
                if (strC2.Length == 0)
                {
                    MessageBox.Show("请选择负责课程二");
                    return;
                }
                if (strDay.Length == 0)
                {
                    MessageBox.Show("请输入休假日期");
                    return;
                }
                if (strCL1.Length == 0)
                {
                    MessageBox.Show("请输入负责课程一");
                    return;
                }
                if (strCL2.Length == 0)
                {
                    MessageBox.Show("请输入负责课程二");
                    return;
                }
                if (strC1 == strC2)
                {
                    MessageBox.Show("所选择的两门课程不能相同!");
                    return;
                }
                if (strCL1 == strCL2)
                {
                    MessageBox.Show("所选择的两负责班级不能相同!");
                    return;
                }
                if (OccupyCheck(strC1, strC2, strCL1, strCL2) == false)
                {
                    string message = string.Format("{0},{1}班级已存在负责课程{2}或{3}的老师", strCL1, strCL2, strC1, strC2);
                    MessageBox.Show(message);
                }
                else
                {
                    int    Cou = 0;
                    string Sql = "insert into z_tmp_teacherinfo (tid_,tname_,course1_,course2_,timeoff,CClass1,CClass2) values(seq_teacher.nextval,'" + strName + "','" + strC1 + "','" + strC2 + "','" + strDay + "','" + strCL1 + "','" + strCL2 + "')";
                    try
                    {
                        Cou = dao.ExecuteNonQuery(Sql);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }

                    if (Cou > 0)
                    {
                        MessageBox.Show("保存成功!");
                        this.Close();
                        log.InfoFormat("添加用户{0}", strName);
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                    }
                }
            }
            if (states == 2)
            {
                if (strName.Length == 0)
                {
                    MessageBox.Show("请输入姓名");
                }
                if (strC1.Length == 0)
                {
                    MessageBox.Show("请输入负责课程一");
                }
                if (strC2.Length == 0)
                {
                    MessageBox.Show("请输入负责课程二");
                }
                if (strDay.Length == 0)
                {
                    MessageBox.Show("请输入休假日期");
                }
                if (strCL1.Length == 0)
                {
                    MessageBox.Show("请输入负责课程一");
                }
                if (strCL2.Length == 0)
                {
                    MessageBox.Show("请输入负责课程二");
                }
                if (strC1 == strC2)
                {
                    MessageBox.Show("所选择的两门课程不能相同!");
                    return;
                }
                if (strCL1 == strCL2)
                {
                    MessageBox.Show("所选择的两负责班级不能相同!");
                    return;
                }
                if (strC1 == strC2)
                {
                    MessageBox.Show("所选择的两门课程不能相同!");
                    return;
                }
                if (strCL1 == strCL2)
                {
                    MessageBox.Show("所选择的两负责班级不能相同!");
                    return;
                }
                if (OccupyCheck(strC1, strC2, strCL1, strCL2) == false)
                {
                    string message = string.Format("{0},{1}班级已存在负责课程{2}或{3}的老师", strCL1, strCL2, strC1, strC2);
                    MessageBox.Show(message);
                }
                else
                {
                    string sql = "update z_tmp_teacherinfo set tname_='" + strName + "',course1_='" + strC1 + "',course2_='" + strC2 + "',timeoff='" + strDay + "',CClass1='" + strCL1 + "',CClass2='" + strCL2 + "' where tid_ = '" + 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("保存失败!");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        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("修改失败!");
                }
            }
        }
Ejemplo n.º 5
0
        private void truncateTable()
        {
            string sql = "truncate table z_tmp_TimeTable";

            dao.ExecuteNonQuery(sql);
        }