Beispiel #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //判断用户是否已输入了必要的信息
            if (this.txtAdminName.Text.Trim() == "" || this.txtAdminPwd.Text.Trim() == "")
            {
                //调用公共类CommonClass中的MessageBox方法
                Response.Write(ccObj.MessageBox("登录名和密码不能为空!"));
            }
            else
            {
                //判断用户输入的验证码是否正确
                if (txtAdminCode.Text.Trim().ToLower() == labCode.Text.Trim().ToLower())
                {
                    //定义一个字符串,获取用户信息

                    DataTable dsTable = employee.GetList("employeeNo=" + this.txtAdminName.Text.Trim() + "AND " + "empPassword="******"AID"]   = Convert.ToInt32(dsTable.Rows[0]["employeeNo"].ToString()); //保存用户ID
                        Session["AName"] = dsTable.Rows[0]["empPassword"].ToString();                 //保存用户名
                        Response.Write("<script language=javascript>window.open('AdminIndex.aspx');window.close();</script>");
                    }
                    else
                    {
                        Response.Write(ccObj.MessageBox("您输入的用户名或密码错误,请重新输入!"));
                    }
                }
                else
                {
                    Response.Write(ccObj.MessageBox("验证码输入有误,请重新输入!"));
                }
            }
        }
Beispiel #2
0
        public void DataBind()//定义一个函数用于绑定数据到DataGridView
        {
            BLL.Employee bll = new BLL.Employee();
            DataSet      ds  = new DataSet();

            ds = bll.GetList();                      //执行SQL语句,将结果存在ds中
            dataGridView1.DataSource = ds.Tables[0]; //将ds中的表作为DataGridView的数据源
        }
Beispiel #3
0
        private void txtOK_Click(object sender, EventArgs e)
        {
            string strSelect = this.cbxCondition.Text.Trim();

            if (strSelect == "")
            {
                MessageBox.Show("请选择查询条件!");
                return;
            }
            if (this.txtKeyWord.Text == "")
            {
                MessageBox.Show("输入查询条件!");
                return;
            }
            string strWhere           = "1=1";
            string employeeName       = txtKeyWord.Text;
            string sex                = txtKeyWord.Text;
            string employeeDepartment = txtKeyWord.Text;
            string employeePost       = txtKeyWord.Text;

            switch (strSelect)
            {
            case "员工姓名":
            {
                strWhere = strWhere + " and EmployeeName like '%" + employeeName + "%'";
            }
            break;

            case "员工性别":
            {
                strWhere = strWhere + " and Sex = '" + sex + "'";
            }
            break;

            case "所属部门":
            {
                strWhere = strWhere + " and EmployeeDepartment like '" + employeeDepartment + "'";
            }
            break;

            case "员工职位":
            {
                strWhere = strWhere + " and EmployeePost like '" + employeePost + "'";
            }
            break;
            }
            BLL.Employee bll = new BLL.Employee(); //实例化BLL层
            DataSet      ds  = new DataSet();

            ds = bll.GetList(strWhere);              //执行带参数SQL语句,将结果存在ds中
            dataGridView1.DataSource = ds.Tables[0]; //将ds中的表作为DataGridView的数据源
        }
Beispiel #4
0
        /// <summary>
        /// 获取员工表中的  员工编号
        /// </summary>
        private void ObtionEmployeeID()
        {
            BLL.Employee bll = new BLL.Employee();
            DataSet      ds  = new DataSet();

            ds = bll.GetList();//执行SQL语句,将结果存在ds中
            if (ds.Tables[0].Rows.Count > 0)
            {
                string[] array = new string[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    array[i] = ds.Tables[0].Rows[i]["员工编号"].ToString();
                    cboEmpID.Items.Add(array[i]);
                }
            }
        }
        private void Employee_Load(object sender, EventArgs e)
        {
            DataBind();//窗体登录时绑定数据到DataGridView
            BLL.Employee bll = new BLL.Employee();
            DataSet      ds  = new DataSet();

            ds = bll.GetList();//执行SQL语句,将结果存在ds中
            if (ds.Tables[0].Rows.Count > 0)
            {
                string[] array = new string[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    array[i] = ds.Tables[0].Rows[i]["员工编号"].ToString();
                    cboEmpID.Items.Add(array[i]);
                }
            }
        }
Beispiel #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string    empName = this.txtName.Text.Trim();
            DataTable dsTable = Bemp.GetList("where=" + empName).Tables[0];

            if (dsTable.Rows.Count > 0)
            {
                Response.Write("该用户名已存在!");
            }
            else
            {
                Memp.empName = this.txtName.Text.Trim();

                Memp.empPassword = this.txtPassWord.Text.Trim();

                Memp.email = this.txtEmail.Text.Trim();
                Bemp.Add(Memp);
                Response.Write("添加成功!");
            }
        }