Exemplo n.º 1
0
        public void LoadData_Teacher()
        {
            if (Maticsoft.Common.StaticDataClass.userType.Equals("管理员"))
            {
                dsTeacher = new Maticsoft.BLL.Teachers().GetList("");
            }
            else
            {
                dsTeacher = new Maticsoft.BLL.Teachers().GetList(String.Format("ID = '{0}'", Maticsoft.Common.StaticDataClass.loginTeacherID));
            }
            dsTeacher.Tables["ds"].Columns["ID"].ColumnName       = "教工号";
            dsTeacher.Tables["ds"].Columns["teaName"].ColumnName  = "姓名";
            dsTeacher.Tables["ds"].Columns["teaSex"].ColumnName   = "性别";
            dsTeacher.Tables["ds"].Columns["teaTitle"].ColumnName = "职称";

            dgvTeacher.DataSource = dsTeacher.Tables["ds"];
            int columnNumber = dgvTeacher.ColumnCount;

            foreach (DataGridViewColumn col in dgvTeacher.Columns)
            {
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                col.SortMode   = DataGridViewColumnSortMode.NotSortable;
                col.FillWeight = 100 / columnNumber;
            }
            dgvTeacher.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvTeacher.AllowUserToAddRows = false;
            dgvTeacher.RowHeadersVisible  = false;
            dgvTeacher.ReadOnly           = true;
        }
Exemplo n.º 2
0
        private void btLogin_Click(object sender, EventArgs e)
        {
            string userName = tbUserName.Text.Trim(),
                   passwd   = tbPasswd.Text.Trim(),
                   userType = combUserType.SelectedItem.ToString().Trim();

            if (userName == "" || userName == null || passwd == "" || passwd == null || userType == "" || userType == null)
            {
                MessageBox.Show("不能有空!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int n = 0;

                switch (userType)
                {
                case "管理员":
                    n = new Maticsoft.BLL.Administrators().GetRecordCount(String.Format("userName = '******' and passwd = '{1}'", userName, passwd));
                    break;

                case "学生":
                    n = new Maticsoft.BLL.Students().GetRecordCount(String.Format("ID = '{0}' and passwd = '{1}'", userName, passwd));
                    Maticsoft.Common.StaticDataClass.loginStudentID = userName;
                    break;

                case "教师":
                    n = new Maticsoft.BLL.Teachers().GetRecordCount(String.Format("ID = '{0}' and passwd = '{1}'", userName, passwd));
                    Maticsoft.Common.StaticDataClass.loginTeacherID = userName;
                    break;
                }

                if (n > 0)
                {
                    MessageBox.Show("登录成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Maticsoft.Common.StaticDataClass.userType = userType;
                    this.Hide();
                    new Main().ShowDialog(this);
                }
                else
                {
                    MessageBox.Show("用户名或密码错误!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Exemplo n.º 3
0
        private void btSearchByTeaName_Click(object sender, EventArgs e)
        {
            Maticsoft.Common.StaticDataClass.teacher.ID = "";
            string name = tbTeaName.Text.Trim();

            if (name == null || name == "")
            {
                MessageBox.Show("不能有空!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DataSet ds = new Maticsoft.BLL.Teachers().GetList(String.Format(" teaName like '%{0}%' ", name));
                if (ds.Tables.Count > 0 && ds.Tables["ds"].Rows.Count > 0)
                {
                    ds.Tables["ds"].Columns["ID"].ColumnName       = "教工号";
                    ds.Tables["ds"].Columns["teaName"].ColumnName  = "姓名";
                    ds.Tables["ds"].Columns["teaSex"].ColumnName   = "性别";
                    ds.Tables["ds"].Columns["teaTitle"].ColumnName = "职称";

                    dgvTeacher.DataSource = ds.Tables["ds"];
                    int columnNumber = dgvTeacher.ColumnCount;
                    foreach (DataGridViewColumn col in dgvTeacher.Columns)
                    {
                        col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                        col.SortMode   = DataGridViewColumnSortMode.NotSortable;
                        col.FillWeight = 100 / columnNumber;
                    }
                    dgvTeacher.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    dgvTeacher.AllowUserToAddRows = false;
                    dgvTeacher.RowHeadersVisible  = false;
                    dgvTeacher.ReadOnly           = true;
                }
                else
                {
                    MessageBox.Show("查无此人!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }