Exemplo n.º 1
0
        GetUserLoginInformationByID(int id)
        {
            UserInformationDetails ent    = null;
            StringBuilder          strSql = new StringBuilder();

            strSql.Append("SELECT * FROM ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.TABLE_NAME);
            strSql.Append(" WHERE ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.ID);
            strSql.Append(" = ");
            strSql.Append(id);
            ManageDataBase database = new
                                      ManageDataBase(DATABASE_TYPE.WarningManagementDB);
            DataTable dt = database.ReturnDS(strSql.ToString()).Tables[0];

            if (dt != null)
            {
                int n = dt.Rows.Count;
                for (int i = 0; i < n; i++)
                {
                    ent                 = new UserInformationDetails();
                    ent.Id              = (int)dt.Rows[i][0];
                    ent.Name            = dt.Rows[i][1].ToString();
                    ent.PhoneNumber     = dt.Rows[i][2].ToString();
                    ent.TelePhoneNumber = dt.Rows[i][3].ToString();
                    ent.Email           = dt.Rows[i][4].ToString();
                    ent.Depratment      = dt.Rows[i][5].ToString();
                    ent.Position        = dt.Rows[i][6].ToString();
                    ent.Remarks         = dt.Rows[i][7].ToString();
                    ent.IsInform        = Convert.ToInt16(dt.Rows[i][8]);
                }
            }
            return(ent);
        }
        /// <summary>
        /// 传入实体,用于实例化时判断为添加、修改。若实体为空,则认为是添加。
        /// </summary>
        /// <param name="ent">用户详细信息实体</param>
        public UserInformationDetailsInput(UserInformationDetails ent)
        {
            InitializeComponent();

            //添加部门名称
            SetComboxDepartment();

            if (ent == null)
            {
                //标记字符,用于告知”确定“执行何种操作
                _strIsAddOrModify = "add";
                //设置窗体格式
                LibCommon.FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, LibCommon.LibFormTitles.USER_INFO_DETAILS_ADD);
            }
            else
            {
                //姓名
                _txtName.Text = ent.Name;
                //手机号码
                _txtPhoneNumber.Text = ent.PhoneNumber;
                //电话
                _txtTel.Text = ent.TelePhoneNumber;
                //邮箱
                _txtEmail.Text = ent.Email;
                //部门
                if (_cboDepartment.Items.Count != 0)//解决部门中无值时的报错问题
                {
                    _cboDepartment.SelectedIndex = GetDepartmentIndex(ent.Depratment);
                }
                //职位
                _txtPosition.Text = ent.Position;
                //备注
                _rtxtRemark.Text = ent.Remarks;

                if (ent.IsInform == 0)
                {
                    rbtnInformNo.Checked  = true;
                    rbtnInformYes.Checked = false;
                }
                else
                {
                    rbtnInformNo.Checked  = false;
                    rbtnInformYes.Checked = true;
                }

                //标记字符,用于告知”确定“执行何种操作
                _strIsAddOrModify = "modify";
                //设置窗体格式
                LibCommon.FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, LibCommon.LibFormTitles.USER_INFO_DETAILS_MOD);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsBtnModify_Click(object sender, EventArgs e)
        {
            if (_userSel.Count == 0)
            {
                //管理界面没有选择时,返回
                return;
            }

            //定义用户登录信息实体,接收旧值,添加到窗体中。旧值来源于管理界面的选择值。可以直接取值,也可从数据库取值,暂不考虑效率,以下代码从数据库取值。
            UserInformationDetails ent = UserInformationDetailsManagementBLL.GetUserLoginInformationByID(_userSel[0]);

            //修改
            UserInformationDetailsInput uidi = new UserInformationDetailsInput(ent);

            uidi.ShowDialog();
            //刷新显示的用户信息
            GetUsersInfoDetails();
        }
Exemplo n.º 4
0
        InsertUserInformationDetailsIntoTable(UserInformationDetails ent)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.TABLE_NAME);
            strSql.Append(" VALUES(");
            strSql.Append("'" + ent.Name + "',");
            strSql.Append("'" + ent.PhoneNumber + "',");
            strSql.Append("'" + ent.TelePhoneNumber + "',");
            strSql.Append("'" + ent.Email + "',");
            strSql.Append("'" + ent.Depratment + "',");
            strSql.Append("'" + ent.Position + "',");
            strSql.Append("'" + ent.Remarks + "',");
            strSql.Append("'" + ent.IsInform + "')");
            ManageDataBase database = new
                                      ManageDataBase(DATABASE_TYPE.WarningManagementDB);

            return(database.OperateDB(strSql.ToString()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取所有登录用户信息
        /// </summary>
        /// <returns>用户登录信息实体数组,无用户信息时返回NULL</returns>
        public static UserInformationDetails[] GetUserInformationDetails()
        {
            UserInformationDetails[] infos  = null;
            StringBuilder            strSql = new StringBuilder();

            strSql.Append("SELECT * FROM ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.TABLE_NAME);
            ManageDataBase database = new
                                      ManageDataBase(DATABASE_TYPE.WarningManagementDB);
            DataTable dt = database.ReturnDS(strSql.ToString()).Tables[0];

            if (dt != null)
            {
                int n = dt.Rows.Count;
                if (n > 0)
                {
                    infos = new UserInformationDetails[n];
                }
                else
                {
                    return(null);
                }
                for (int i = 0; i < n; i++)
                {
                    UserInformationDetails info = new
                                                  UserInformationDetails();
                    info.Id              = (int)dt.Rows[i][0];
                    info.Name            = dt.Rows[i][1].ToString();
                    info.PhoneNumber     = dt.Rows[i][2].ToString();
                    info.TelePhoneNumber = dt.Rows[i][3].ToString();
                    info.Email           = dt.Rows[i][4].ToString();
                    info.Depratment      = dt.Rows[i][5].ToString();
                    info.Position        = dt.Rows[i][6].ToString();
                    info.Remarks         = dt.Rows[i][7].ToString();
                    info.IsInform        = Convert.ToInt16(dt.Rows[i][8]);
                    infos[i]             = info;
                }
            }
            return(infos);
        }
Exemplo n.º 6
0
        UpdataUserInformationDetails(UserInformationDetails ent, int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.TABLE_NAME);
            strSql.Append(" SET ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_NAME
                          + " = ");
            strSql.Append("'" + ent.Name + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_PHONENUMBER
                          + " = ");
            strSql.Append("'" + ent.PhoneNumber + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_TELEPHONE
                          + " = ");
            strSql.Append("'" + ent.TelePhoneNumber + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_EMAIL
                          + " = ");
            strSql.Append("'" + ent.Email + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_DEPARTMENT
                          + " = ");
            strSql.Append("'" + ent.Depratment + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_POSITION
                          + " = ");
            strSql.Append("'" + ent.Position + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_REMARKS
                          + " = ");
            strSql.Append("'" + ent.Remarks + "',");
            strSql.Append(UserInformationDetailsManagementDbConstNames.USER_ISINFORM
                          + " = ");
            strSql.Append("'" + ent.IsInform + "'");
            strSql.Append(" WHERE ");
            strSql.Append(UserInformationDetailsManagementDbConstNames.ID +
                          "=");
            strSql.Append(id);
            ManageDataBase database = new
                                      ManageDataBase(DATABASE_TYPE.WarningManagementDB);

            return(database.OperateDB(strSql.ToString()));
        }
        /// <summary>
        /// 点击确定按钮出发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            //定义接收界面信息的实体
            UserInformationDetails ent = new UserInformationDetails();

            //姓名
            ent.Name = _txtName.Text;
            //手机号码
            ent.PhoneNumber = _txtPhoneNumber.Text;
            //电话号码
            ent.TelePhoneNumber = _txtTel.Text;
            //邮箱
            ent.Email = _txtEmail.Text;

            ent.IsInform = rbtnInformNo.Checked == true ? 0 : 1;
            //部门
            if (_cboDepartment.SelectedItem != null)
            {
                ent.Depratment = _cboDepartment.SelectedItem.ToString();
            }
            //职称
            ent.Position = _txtPosition.Text;
            //备注
            ent.Remarks = _rtxtRemark.Text;

            //姓名不能存在特殊字符,且不能为空
            if (LibCommon.Validator.checkSpecialCharacters(ent.Name) || LibCommon.Validator.IsEmptyOrBlank(ent.Name))
            {
                Alert.alert(LibCommon.Const.NAME_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                _txtName.Focus();

                //解决return后,窗体消失的bug
                DialogResult = DialogResult.None;
                return;
            }

            //检查手机号码,可以为空但不能格式错误
            //if (_txtPhoneNumber.Text != "")
            //{
            //    if (!LibCommon.Validator.checkIsPhoneNumber(_txtPhoneNumber.Text))
            //    {
            //        Alert.alert(LibCommon.Const.PHONE_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        this._txtPhoneNumber.Focus();
            //        return;
            //    }
            //}

            //检查电话号码,可以为空但不能格式错误
            //if (_txtTel.Text != "")
            //{
            //    if (!LibCommon.Validator.checkIsIsTelePhone(_txtTel.Text))
            //    {
            //        Alert.alert(LibCommon.Const.TEL_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        this._txtTel.Focus();
            //        return;
            //    }
            //}

            //检查邮箱,可以为空但不能格式错误
            if (_txtEmail.Text != "")
            {
                if (!LibCommon.Validator.checkIsEmailAddress(_txtEmail.Text))
                {
                    Alert.alert(LibCommon.Const.EMAIL_IS_WRONG, LibCommon.Const.NOTES, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this._txtEmail.Focus();
                    return;
                }
            }

            //添加
            if (_strIsAddOrModify == "add")
            {
                //添加用户详细信息
                UserInformationDetailsManagementBLL.InsertUserInformationDetailsIntoTable(ent);
            }
            //修改。操作是仍需记录管理界面赋值的Id,(_userSel[0])中存放
            else if (_strIsAddOrModify == "modify")
            {
                //修改用户详细信息
                UserInformationDetailsManagementBLL.UpdataUserInformationDetails(ent, UserInformationDetailsManagement._userSel[0]);
            }
            this.Close();
        }