Ejemplo n.º 1
0
        protected void showEmploryee()
        {
            StringBuilder sSql = new StringBuilder();

            sSql.Append(" select * from Emploryee ");
            sSql.AppendFormat("where EpId={0}", EmpId);
            sqlHelper     helper = new sqlHelper();
            SqlDataReader dr     = helper.ExecuteRead(helper.connectionStr, sSql.ToString());

            if (dr.Read())
            {
                txtEmploryeeName.Text = dr["EpName"].ToString().Trim();
                switch (dr["gender"].ToString().Trim())
                {
                case "1":
                    this.rbtBoy.Checked = true;
                    break;

                case "0":
                    this.rbtGirl.Checked = true;
                    break;
                }
                txtCellPhoneNum.Text      = dr["MobilePhone"].ToString().Trim();
                txtTelephoneNum.Text      = dr["officePhone"].ToString().Trim();
                txtAddress.Text           = dr["Address"].ToString().Trim();
                cmbDepart.SelectedValue   = (int)dr["DptId"];
                cmbPosition.SelectedValue = (int)dr["PId"];
            }
            dr.Close();
        }
Ejemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                StringBuilder sSql = new StringBuilder();
                sSql.AppendFormat("select LoginPwd from Users where LoginPwd='{0}'", txtUserPwd.Text.ToString().Trim());
                sSql.AppendFormat(" and LoginId='{0}'", Common.UserName);
                sqlHelper     helper = new sqlHelper();
                SqlDataReader dr     = helper.ExecuteRead(helper.connectionStr, sSql.ToString());
                if (dr.Read())
                {
                    if (dr["LoginPwd"].ToString().Trim() == txtUserPwd.Text.ToString().Trim())
                    {
                        this.Dispose();
                    }
                }
                else
                {
                    MessageBox.Show("密码不正确!请重新输入!", Common.APTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    PwdErrorCount++;
                }

                if (PwdErrorCount >= 3)
                {
                    MessageBox.Show("您已连续3次输入密码错误,系统已被完全锁定,请两分钟之后再次重试!");
                    linkLabel2.Text  = "密码输入3次错误,请两分钟之后重试!";
                    timer1.Enabled   = true;  //开启计时器
                    btnLogin.Enabled = false; //禁用解锁按钮
                }
            }
        }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult delResult = MessageBox.Show("您确定要删除吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (delResult == DialogResult.Yes)
            {
                StringBuilder delSb = new StringBuilder();
                foreach (DataGridViewRow row in dgvDepart.SelectedRows)
                {
                    if (row.Cells["deptId"].Value != null)
                    {
                        delSb.Append(row.Cells["deptId"].Value.ToString().Trim());
                        delSb.Append(",");
                    }
                }
                if (delSb.Length == 0)
                {
                    MessageBox.Show("您还没有选择删除项");
                    return;
                }

                delSb.Remove(delSb.Length - 1, 1);
                StringBuilder ExitPoxSb = new StringBuilder();
                ExitPoxSb.Append(" select dept.DeptName from Position pos inner join Depart dept on pos.DeptId=dept.DeptId");
                ExitPoxSb.Append(" where pos.DeptId in (");
                ExitPoxSb.Append(delSb.ToString());
                ExitPoxSb.Append(")");
                ExitPoxSb.Append(" group by dept.DeptName");
                sqlHelper     helper     = new sqlHelper();
                SqlDataReader dr         = helper.ExecuteRead(helper.connectionStr, ExitPoxSb.ToString());
                StringBuilder DeptNameSb = new StringBuilder();
                while (dr.Read())
                {
                    DeptNameSb.Append(dr["DeptName"].ToString().Trim());
                    DeptNameSb.Append(",");
                }
                if (DeptNameSb.Length > 0)
                {
                    DeptNameSb.Remove(DeptNameSb.Length - 1, 1);
                    MessageBox.Show("不能删除!一下的部门正在使用" + DeptNameSb.ToString());
                    return;
                }

                delSb.Insert(0, "delete Depart where DeptId in (");
                delSb.Append(")");

                int result = helper.ExecuteNonQuery(helper.connectionStr, delSb.ToString());
                if (result > 0)
                {
                    MessageBox.Show("删除成功");
                    QueryDepart();
                }
                else
                {
                    MessageBox.Show("删除失败");
                }
            }
        }
Ejemplo n.º 4
0
        public static string GetEmploryeeNameByEpId(int EpId)
        {
            string        EmploryeeName = null;
            string        sSql          = "select EpName from Emploryee where EpId= " + EpId;
            sqlHelper     helper        = new sqlHelper();
            SqlDataReader dr            = helper.ExecuteRead(helper.connectionStr, sSql);

            if (dr.Read())
            {
                EmploryeeName = dr["EpName"].ToString().Trim();
            }
            return(EmploryeeName);
        }
Ejemplo n.º 5
0
        private bool CheckAdmin()
        {
            bool isValidAdmin = false;

            Common.UserName = cmbUserName.Text.Trim();
            Common.UserPwd  = txtUserPwd.Text.Trim();

            StringBuilder sSql = new StringBuilder();

            sSql.Append("select LoginId,LoginPwd,us.epId,ep.EpName from Users us inner join Emploryee ep on us.epId=ep.epId ");
            sSql.AppendFormat("where LoginId='{0}' and LoginPwd='{1}'", cmbUserName.Text.Trim(), txtUserPwd.Text.Trim());
            sSql.Append(" and ep.flag=0 ");
            sqlHelper helper = new sqlHelper();

            try
            {
                SqlDataReader dr = helper.ExecuteRead(helper.connectionStr, sSql.ToString());

                if (dr.Read())
                {
                    Common.EpId   = Convert.ToInt32(dr["epId"]);
                    Common.EpName = dr["EpName"].ToString().Trim();
                    if (dr["LoginId"].ToString().Trim() == Common.UserName && dr["LoginPwd"].ToString().Trim() == Common.UserPwd)
                    {
                        isValidAdmin = true;
                    }
                    else
                    {
                        Common.Message = "用户名或密码不正确!";
                        isValidAdmin   = false;
                    }
                }
                dr.Close();
            }
            catch (Exception)
            {
                Common.Message = "系统维护,请稍后再试!";
                isValidAdmin   = false;
            }

            return(isValidAdmin);
        }
Ejemplo n.º 6
0
        private void showDept()
        {
            //StringBuilder sSql=new StringBuilder();
            //sSql.Append("select de.DeptId,de.DeptName,pn.DeptName ");
            //sSql.Append(" from(select DeptName from Depart where DeptId= ");
            //sSql.AppendFormat(" (select parentId from Depart where DeptId={0})) pn, Depart de ",DeptId);
            //sSql.AppendFormat(" where DeptId={0} ",DeptId);
            string        sSql   = "select * from Depart where DeptId=" + DeptId;
            sqlHelper     helper = new sqlHelper();
            SqlDataReader dr     = helper.ExecuteRead(helper.connectionStr, sSql);

            if (dr.Read())
            {
                cmbDepartFather.SelectedValue = (int)dr["parentId"];
                txtDeptName.Text = dr["DeptName"].ToString().Trim();
                if (flag == 2)
                {
                    txtDepartId.Text = DeptId.ToString().Trim();
                }
            }
            dr.Close();
        }