/// <summary>
        /// Add a record
        /// </summary>
        public int Insert(UsersEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Users(");
            strSql.Append("CompanyID,RoleID,FirstName,LastName,UserName,Email,PassWord,Title,Phone,EmergencyContactFirstName,EmergencyContactLastName")
            .Append(",EmergencyContactPhone,EmergencyContactEmail,MaintenancePlanOption")
            .Append(",CreatedOn,AccountStatus,ForgotPassword,IsDelete,Status,UserType,Skype,Office,PTOHoursOfYear)");

            strSql.Append(" values (");
            strSql.Append("@CompanyID,@RoleID,@FirstName,@LastName,@UserName,@Email,@PassWord,@Title,@Phone,@EmergencyContactFirstName,@EmergencyContactLastName")
            .Append(",@EmergencyContactPhone,@EmergencyContactEmail,@MaintenancePlanOption")
            .Append(",@CreatedOn,@AccountStatus,@ForgotPassword,@IsDelete,@Status,@UserType,@Skype,@Office,@PTOHoursOfYear)");
            strSql.Append(";select ISNULL( SCOPE_IDENTITY(),0);");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "CompanyID", DbType.Int32, model.CompanyID);
                    db.AddInParameter(dbCommand, "RoleID", DbType.Int32, model.RoleID);
                    db.AddInParameter(dbCommand, "FirstName", DbType.String, model.FirstName);
                    db.AddInParameter(dbCommand, "LastName", DbType.String, model.LastName);
                    db.AddInParameter(dbCommand, "UserName", DbType.String, model.UserName);
                    db.AddInParameter(dbCommand, "Email", DbType.String, model.Email);
                    db.AddInParameter(dbCommand, "PassWord", DbType.String, model.PassWord);
                    db.AddInParameter(dbCommand, "Title", DbType.String, model.Title);
                    db.AddInParameter(dbCommand, "Phone", DbType.String, model.Phone);
                    db.AddInParameter(dbCommand, "EmergencyContactFirstName", DbType.String, model.EmergencyContactFirstName);
                    db.AddInParameter(dbCommand, "EmergencyContactLastName", DbType.String, model.EmergencyContactLastName);
                    db.AddInParameter(dbCommand, "EmergencyContactPhone", DbType.String, model.EmergencyContactPhone);
                    db.AddInParameter(dbCommand, "EmergencyContactEmail", DbType.String, model.EmergencyContactEmail);
                    db.AddInParameter(dbCommand, "MaintenancePlanOption", DbType.String, model.MaintenancePlanOption);
                    db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, model.CreatedOn);
                    db.AddInParameter(dbCommand, "AccountStatus", DbType.Int32, model.AccountStatus);
                    db.AddInParameter(dbCommand, "ForgotPassword", DbType.Int32, model.ForgotPassword);
                    db.AddInParameter(dbCommand, "IsDelete", DbType.Boolean, model.IsDelete);
                    db.AddInParameter(dbCommand, "Status", DbType.String, model.Status);
                    db.AddInParameter(dbCommand, "UserType", DbType.String, model.UserType);
                    db.AddInParameter(dbCommand, "Skype", DbType.String, model.Skype);
                    db.AddInParameter(dbCommand, "Office", DbType.String, model.Office);
                    db.AddInParameter(dbCommand, "PTOHoursOfYear", DbType.Double, model.PTOHoursOfYear);

                    int    result;
                    object obj = db.ExecuteScalar(dbCommand);
                    if (!int.TryParse(obj.ToString(), out result))
                    {
                        return(0);
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                    return(0);
                }
            }
        }
        List <CalendarView> BuilderList(List <EventEntity> eventList, DateTime start, int userId, int dateCount)
        {
            List <CalendarView> list = new List <CalendarView>();
            int count = 1;

            foreach (EventEntity entity in eventList.FindAll(r => r.FromDay.Date == start.Date))
            {
                ///每个日期格子只显示 dateCount 条记录
                if (count > dateCount)
                {
                    break;
                }
                count++;
                int inviteStatus = 0;

                UsersEntity user = null;
                list.Add(new CalendarView()
                {
                    ID           = entity.ID,
                    Title        = BuilderTitle(entity),
                    Name         = entity.Name,
                    Icon         = EventIconAgent.BuidlerIcon(entity.Icon),
                    date         = BuilderTime(entity),
                    CreatedAt    = entity.CreatedBy,
                    Invited      = user != null,
                    FullName     = user == null ? "" : string.Format("{0} {1}", user.FirstName, user.LastName),
                    IsEdit       = entity.FromDay >= DateTime.Now.Date,
                    InviteStatus = inviteStatus,
                    Times        = entity.Times
                });
            }
            return(list);
        }
Beispiel #3
0
        private void txtEnter_Click(object sender, EventArgs e)
        {
            string check = checkData();

            if (check != null)
            {
                MessageBox.Show(check);
                return;
            }
            UsersBS     isb      = new UsersBS();
            UsersEntity entity   = new UsersEntity();
            string      userName = txtUserName.Text;
            string      password = txtPassword.Text;

            entity = isb.checkUser(userName, password, _checkJustManager);
            int userCount = entity.Tables[entity.FilledTableName].Rows.Count;

            if (userCount > 0)
            {
                UsersBS.loginedUser            = entity;
                UsersBS.LogginedUserProperties = new UserpropertiesBL().get(int.Parse(entity.get(UsersEntity.FIELD_ID).ToString()));
                _loggined = true;
                this.Hide();
            }
            else
            {
                MessageBox.Show("نام کاربر یا کلمه عبور معتبر نیست! چنین کاربری یافت نشد!");
            }
        }
Beispiel #4
0
        public string GetUserTicketsHtml(UsersEntity user, List <TimeSheetTicket> tickets)
        {
            StringBuilder ticketsHtml = new StringBuilder();
            bool          firstRow    = true;
            decimal       totalHours  = 0;

            string firstTmp = UserFirstRowSection;
            string content  = UserContentSection;

            foreach (TimeSheetTicket ticket in tickets)
            {
                string tmp = firstRow ? firstTmp : content;
                tmp = tmp.Replace("{UserName}", string.Format("{0} {1}", user.FirstName, user.LastName));
                tmp = tmp.Replace("{Project}", ticket.ProjectTitle);
                tmp = tmp.Replace("{Ticket}", ticket.TicketTitle);
                tmp = tmp.Replace("{Description}", ticket.WorkDetail);
                tmp = tmp.Replace("{Percent}", ticket.Percentage.ToString());
                tmp = tmp.Replace("{Hour}", ticket.Hours.ToString());
                ticketsHtml.Append(tmp);
                firstRow    = false;
                totalHours += ticket.Hours;
            }
            ticketsHtml.Replace("{Rowspan}", tickets.Count.ToString());
            ticketsHtml.Replace("{TotalHour}", totalHours.ToString());
            if (totalHours < 8)
            {
                ticketsHtml.Replace("{BackgroundColor_Css}", "td_yellow");
            }
            else
            {
                ticketsHtml.Replace("{BackgroundColor_Css}", "td_blue");
            }
            return(ticketsHtml.ToString());
        }
        protected UsersEntity GetEntity()
        {
            IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES);

            string[] items = encrypt.Decrypt(Request.Params["link"]).Split("_".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (items.Length != 2)
            {
                return(null);
            }
            int      userid;
            DateTime date;

            if (!int.TryParse(items[0], out userid) || !DateTime.TryParse(items[1], out date))
            {
                return(null);
            }
            if (date.Date != DateTime.Now.Date)
            {
                return(null);
            }
            UserApplication userApp = new UserApplication();
            UsersEntity     user    = userApp.GetUser(userid, false);

            return(user);
        }
Beispiel #6
0
        Task <T> IUserEmailStore <T, string> .FindByEmailAsync(string email)
        {
            if (string.IsNullOrEmpty(_connectionString))
            {
                _connectionString = GetClientConnectionString();
            }
            CompanyFacade fac = new CompanyFacade(_connectionString, Helper.UserName);

            if (string.IsNullOrWhiteSpace(email))
            {
                throw new ArgumentNullException("email");
            }

            return(Task.Factory.StartNew(() =>
            {
                UsersEntity oUser = fac.GetUserByEmail(email);
                if (oUser == null)
                {
                    return null;
                }
                else
                {
                    return (T)(new ApplicationUser(oUser));
                }
            }));
        }
Beispiel #7
0
        Task <T> IUserStore <T, string> .FindByNameAsync(string EmailAddress)
        {
            if (string.IsNullOrEmpty(_connectionString))
            {
                _connectionString = GetClientConnectionString();
            }
            string        GetConnctionstring = Convert.ToString(_connectionString);
            CompanyFacade fac = new CompanyFacade(GetConnctionstring, Helper.UserName);

            if (string.IsNullOrWhiteSpace(EmailAddress))
            {
                throw new ArgumentNullException("userName");
            }

            return(Task.Factory.StartNew(() =>
            {
                UsersEntity oUser = fac.StewUserLogIn(EmailAddress, null, true);
                if (oUser == null)
                {
                    return null;
                }
                else
                {
                    return (T)(new ApplicationUser(oUser));
                }
            }));
        }
Beispiel #8
0
        /// <summary>
        /// Returns the list of admin users
        /// </summary>
        /// <param name="packageName"></param>
        /// <param name="username"></param>
        /// <param name="jwtUsername"></param>
        /// <returns></returns>
        public async Task <IReadOnlyList <string> > GetAdminUsers(string packageName,
                                                                  string jwtUsername)
        {
            UsersEntity userEntity = await this._dynamoDbService.GetItemAsync <UsersEntity>(jwtUsername);

            if (userEntity == null)
            {
                throw new Exception("This user does not exist");
            }

            PackageDetailsEntity packageDetails =
                await this._dynamoDbService.GetItemAsync <PackageDetailsEntity>(packageName);

            if (packageDetails == null)
            {
                throw new Exception("No package found");
            }

            if (!string.IsNullOrEmpty(packageDetails.Team))
            {
                throw new Exception("Please use the teams API method to get list of admin memebers");
            }

            if (!packageDetails.AdminUsers.Contains(jwtUsername))
            {
                throw new Exception("You are not allowed to get a list of all admin users");
            }

            return((IReadOnlyList <string>)packageDetails.AdminUsers);
        }
        public UsersEntity Get(int id)
        {
            var users = new UsersEntity();

            using (var con = new SqlConnection(connectionString))
            {
                con.Open();
                var cmd = new SqlCommand("SELECT * FROM UserDetails WHERE id= @id", con);
                cmd.Parameters.AddWithValue("@id", id);

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        users.UserID     = dr.GetString(1);
                        users.FirstName  = dr.GetString(2);
                        users.LastName   = dr.GetString(3);
                        users.Gender     = dr.GetString(4);
                        users.DOB        = Convert.ToDateTime(dr[5]);
                        users.IsActive   = dr.GetBoolean(6);
                        users.CreateDate = Convert.ToDateTime(dr[7]);
                    }
                }
            }

            return(users);
        }
Beispiel #10
0
        private void createTree(UserTreeEntity entity, TreeNode node)
        {
            UsersEntity userEntity = null;

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                int childUserId = int.Parse(entity.get(i, UserTreeEntity.FIELD_USER_ID).ToString());
                int parentId    = int.Parse(entity.get(i, UserTreeEntity.FIELD_ID).ToString());
                userEntity = _usersBS.get(childUserId);
                TreeNode newNode = null;
                if (node == null)
                {
                    node           = new TreeNode(userEntity.ToString(i));
                    node.Tag       = NodeItem.ToNodeItem(entity, i);
                    node.ForeColor = Color.Green;
                    treeView1.Nodes.Add(node);
                    newNode = node;
                }
                else
                {
                    newNode           = new TreeNode(userEntity.ToString());
                    newNode.Tag       = NodeItem.ToNodeItem(entity, i);
                    newNode.ForeColor = Color.Green;
                    node.Nodes.Add(newNode);
                }

                createTree(_userTreeBL.getByParent(parentId), newNode);
            }
        }
Beispiel #11
0
        private void initTree()
        {
            UsersEntity    entity         = _usersBS.get(UsersEntity.FIELD_USER_TYPE + "=" + UsersBS.ADMIN);
            UserTreeEntity userTreeEntity = null;

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                userTreeEntity = new UserTreeEntity();
                DataRow dr = userTreeEntity.Tables[userTreeEntity.TableName].NewRow();
                dr[UserTreeEntity.FIELD_USER_ID]   = entity.get(UsersEntity.FIELD_ID);
                dr[UserTreeEntity.FIELD_USER_PATH] = entity.get(UsersEntity.FIELD_ID).ToString();
                userTreeEntity.Tables[userTreeEntity.TableName].Rows.Add(dr);
                _userTreeBL.add(userTreeEntity);
            }

            userTreeEntity = _userTreeBL.get();
            for (int i = 0; i < userTreeEntity.Tables[userTreeEntity.FilledTableName].Rows.Count; i++)
            {
                entity = _usersBS.get(int.Parse(userTreeEntity.get(UserTreeEntity.FIELD_USER_ID).ToString()));
                TreeNode node = new TreeNode(entity.ToString());
                node.ForeColor = Color.Green;
                node.Tag       = NodeItem.ToNodeItem(userTreeEntity, i);
                treeView1.Nodes.Add(node);
            }
        }
Beispiel #12
0
        public HtmlGenericControl GetUserLi(UsersEntity user, bool isCreate, bool isChecked, bool isUS = false)
        {
            HtmlGenericControl li = new HtmlGenericControl("li");

            if (isCreate)
            {
                li.Style.Add("display", "none");
                li.Attributes.Add("data-isCreate", "true");
            }

            // li.Attributes.Add("title", user.FirstName + " " + user.LastName);
            CheckBox chkBox = new CheckBox()
            {
                ID = "chk-" + user.ID, Text = "  " + BasePage.GetClientUserName(user)
            };

            chkBox.Attributes.Add("data-role", ((int)MapRoleToTicketUserType(user.Role)).ToString());
            chkBox.Attributes.Add("data-id", user.ID.ToString());
            if (isUS)
            {
                chkBox.Attributes.Add("data-us", "1");
            }

            if (isChecked)
            {
                chkBox.Checked = true;
            }
            li.Controls.Add(chkBox);
            return(li);
        }
Beispiel #13
0
        protected void iBtnDownload_Click(object sender, ImageClickEventArgs e)
        {
            SearchTimeSheetsRequest request = new SearchTimeSheetsRequest(SearchType.QueryReport,
                                                                          false, hidOrderBy.Value, hidOrderDirection.Value);

            request.Keywords    = txtKeyword.Text;
            request.CurrentPage = anpTimesheet.CurrentPageIndex;
            request.PageCount   = anpTimesheet.PageSize;
            request.ProjectID   = int.Parse(ddlProject.SelectedValue);
            request.TicketID    = int.Parse(ddlTickets.SelectedValue);
            request.UserID      = int.Parse(ddlUsers.SelectedValue);

            request.StartDate = StartDate;
            request.EndDate   = EndDate;

            if (ddlProject.SelectedIndex != 0)
            {
                request.OrderExpression = "ticketcode, sheetdate";
                request.OrderDirection  = "asc";
            }
            SearchTimeSheetsResponse response = tsApp.QueryTimesheet(request);
            UserApplication          userApp  = new UserApplication();

            UsersEntity model  = userApp.GetUser(int.Parse(ddlUsers.SelectedValue));
            ExcelReport report = new ExcelReport();

            report.Generate(response.TimeSheetsList, model, ddlProject.SelectedItem.Text, DateTime.Now);
        }
Beispiel #14
0
        public static void fillComboWithUsers(ComboBox cmb, int defaultId)
        {
            UsersDA     da     = new UsersDA();
            String      cond   = "ACTIVE=1";
            UsersEntity entity = da.load(cond);

            var dataSource = new List <ComboBoxItem>();

            cmb.DataSource = null;
            cmb.Items.Clear();
            BasicInfoUtil.AddUnKnown(dataSource);

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
            {
                string name = entity.get(i, UsersEntity.FIELD_NAME) + " " + entity.get(i, UsersEntity.FIELD_FAMILY) + " ( " +
                              entity.get(i, UsersEntity.FIELD_USERNAME) + " ) ";
                string id = entity.get(i, UsersEntity.FIELD_ID).ToString();

                dataSource.Add(new ComboBoxItem(name, id));
            }

            cmb.DataSource    = dataSource;
            cmb.DisplayMember = "Text";
            cmb.ValueMember   = "Value";
            for (int i = 0; i < cmb.Items.Count; i++)
            {
                if (((ComboBoxItem)cmb.Items[i]).Value.Equals(defaultId.ToString()))
                {
                    cmb.SelectedIndex = i;
                    break;
                }
            }
        }
Beispiel #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            listPorject = proApp.GetUserProjects(UserInfo);
            if (!IsPostBack)
            {
                userEntity = UserInfo;
                string userId = QS("userid");
                if (!string.IsNullOrEmpty(userId))
                {
                    userEntity  = userApp.GetUser(int.Parse(userId));
                    listPorject = proApp.GetUserProjects(userEntity);
                }

                pid = QS("pid");
                FillSearchDto();
                // Buring 2013_10_14 contactordev select
                if (this.userEntity.Role == RolesEnum.Contactor)
                {
                    ddlAssignUser.SelectedValue = this.userEntity.UserID.ToString();
                    ddlAssignUser.Enabled       = false;
                }

                TicketsDataBind();

                if (!string.IsNullOrEmpty(pid))
                {
                    if (!CheckSecurity(Convert.ToInt32(pid)))
                    {
                        Response.Redirect("~/SunnetTicket/dashboard.aspx");
                        return;
                    }
                }
            }
        }
Beispiel #16
0
        /// <summary>
        /// 得到  users 数据实体
        /// </summary>
        /// <param name="row">row</param>
        /// <returns>users 数据实体</returns>
        public UsersEntity Populate_UsersEntity_FromDr(DataRow row)
        {
            UsersEntity Obj = new UsersEntity();

            if (row != null)
            {
                Obj.Id         = ((row["Id"]) == DBNull.Value) ? 0 : (long)row["Id"];
                Obj.UserCode   = row["UserCode"].ToString();
                Obj.UserName   = row["UserName"].ToString();
                Obj.Password   = row["Password"].ToString();
                Obj.UserType   = row["UserType"].ToString();
                Obj.Point      = ((row["Point"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["Point"]);
                Obj.Phone      = row["Phone"].ToString();
                Obj.CreateBy   = row["CreateBy"].ToString();
                Obj.CreateTime = ((row["CreateTime"]) == DBNull.Value) ? Convert.ToDateTime("1900-1-1") : Convert.ToDateTime(row["CreateTime"]);
                Obj.UpdateTime = ((row["UpdateTime"]) == DBNull.Value) ? Convert.ToDateTime("1900-1-1") : Convert.ToDateTime(row["UpdateTime"]);
                Obj.IsActive   = ((row["IsActive"]) == DBNull.Value) ? (short)0 : (short)row["IsActive"];
                Obj.Memo       = row["Memo"].ToString();
            }
            else
            {
                return(null);
            }
            return(Obj);
        }
Beispiel #17
0
        Task <IList <string> > IUserRoleStore <T, string> .GetRolesAsync(T user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            if (string.IsNullOrEmpty(_connectionString))
            {
                _connectionString = GetClientConnectionString();
            }
            CompanyFacade fac   = new CompanyFacade(_connectionString, Helper.UserName);
            UsersEntity   oUser = fac.StewUserLogIn(user.EmailAddress, null, true);

            return(Task.Factory.StartNew(() =>
            {
                IList <string> newList = null;
                List <string> role = new List <string>();
                role.Add("Admin");
                if (!string.IsNullOrEmpty(oUser.UserType))
                {
                    role.Add(oUser.UserType);
                }
                newList = role;
                return newList;
            }));
        }
Beispiel #18
0
        /// <summary>
        /// 根据ID,返回一个Users对象
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>Users对象</returns>
        public UsersEntity Get_UsersEntity(long id)
        {
            UsersEntity _obj = null;

            SqlParameter[] _param =
            {
                new SqlParameter("@Id", SqlDbType.BigInt)
            };
            _param[0].Value = id;
            string sqlStr = "select * from Users with(nolock) where Id=@Id  and isactive=1 ";

            using (SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.Connection, CommandType.Text, sqlStr, _param))
            {
                while (dr.Read())
                {
                    _obj = Populate_UsersEntity_FromDr(dr);
                }

                if (!dr.IsClosed)
                {
                    dr.Close();
                }
            }
            return(_obj);
        }
Beispiel #19
0
        Task <T> IUserStore <T, string> .FindByIdAsync(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            if (string.IsNullOrEmpty(_connectionString))
            {
                _connectionString = GetClientConnectionString();
            }
            SettingFacade fac = new SettingFacade(_connectionString);
            int           parsedUserId;

            if (!int.TryParse(userId, out parsedUserId))
            {
                throw new ArgumentOutOfRangeException("userId", string.Format("'{0}' is not a valid GUID.", new { userId }));
            }

            return(Task.Factory.StartNew(() =>
            {
                UsersEntity oUser = fac.GetUserDetailsById(Convert.ToInt32(userId));
                if (oUser == null)
                {
                    return null;
                }
                else
                {
                    return (T)(new ApplicationUser(oUser));
                }
            }));
        }
Beispiel #20
0
        /// <summary>
        /// 检查登录
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool IsAllowedLogin(UsersEntity user)
        {
            bool   allowed = false;
            string str     = "select count(1) from Users where UserCode=@UserCode and Password = @Password";

            SqlParameter[] para =
            {
                new SqlParameter("@UserCode", user.UserCode),
                new SqlParameter("@Password", user.Password)
            };

            var obj = SqlHelper.ExecuteScalar(SqlHelper.Connection, CommandType.Text, str, para);

            if (null == obj)
            {
                return(allowed);
            }
            int result = 0;

            if (int.TryParse(obj.ToString(), out result))
            {
                if (result > 0)
                {
                    allowed = true;
                }
            }
            return(allowed);
        }
        public UsersEntity CreataUser(UsersEntity user)
        {
            var newUser = PrepareUsersEntityToUser(user);

            _user.AddUser(newUser);
            return(user);
        }
Beispiel #22
0
        /// <summary>
        /// 向数据库中插入一条新记录。
        /// </summary>
        /// <param name="_UsersModel">Users实体</param>
        /// <returns>新插入记录的编号</returns>
        public long Insert(UsersEntity _UsersModel)
        {
            string sqlStr = "insert into Users([UserCode],[UserName],[Password],[UserType],[Point],[Phone],[CreateBy],[CreateTime],[UpdateTime],[IsActive],[Memo]) values(@UserCode,@UserName,@Password,@UserType,@Point,@Phone,@CreateBy,@CreateTime,@UpdateTime,@IsActive,@Memo) select @@identity";
            long   res;

            SqlParameter[] _param =
            {
                new SqlParameter("@UserCode",   SqlDbType.VarChar),
                new SqlParameter("@UserName",   SqlDbType.VarChar),
                new SqlParameter("@Password",   SqlDbType.VarChar),
                new SqlParameter("@UserType",   SqlDbType.VarChar),
                new SqlParameter("@Point",      SqlDbType.Int),
                new SqlParameter("@Phone",      SqlDbType.VarChar),
                new SqlParameter("@CreateBy",   SqlDbType.VarChar),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime),
                new SqlParameter("@IsActive",   SqlDbType.SmallInt),
                new SqlParameter("@Memo",       SqlDbType.VarChar)
            };
            _param[0].Value  = _UsersModel.UserCode;
            _param[1].Value  = _UsersModel.UserName;
            _param[2].Value  = _UsersModel.Password;
            _param[3].Value  = _UsersModel.UserType;
            _param[4].Value  = _UsersModel.Point;
            _param[5].Value  = _UsersModel.Phone;
            _param[6].Value  = _UsersModel.CreateBy;
            _param[7].Value  = _UsersModel.CreateTime;
            _param[8].Value  = _UsersModel.UpdateTime;
            _param[9].Value  = _UsersModel.IsActive;
            _param[10].Value = _UsersModel.Memo;
            res = Convert.ToInt64(SqlHelper.ExecuteScalar(SqlHelper.Connection, CommandType.Text, sqlStr, _param));
            return(res);
        }
Beispiel #23
0
        private void InitControls(UsersEntity model)
        {
            ddlUserType.Enabled       = false;
            ddlUserType.SelectedValue = model.UserType;

            //ddlCompany.Enabled = false;
            ddlCompany.SelectedValue = model.CompanyID.ToString();

            ddlRole.SelectedValue = model.RoleID.ToString();

            if (IsSunnet)
            {
                ddlOffice.SelectedValue = model.Office;
            }
            else
            {
                ddlRole.Enabled = false;
                // Advance Infomation Client
                txtEFirstName.Text = model.EmergencyContactFirstName;
                txtELastName.Text  = model.EmergencyContactLastName;
                txtEEmail.Text     = model.EmergencyContactEmail;
                txtEPhone.Text     = model.EmergencyContactPhone;
                //ClientMaintenancePlan1.SelectedMaintenancePlan = model.MainPlanOption;
            }
            // basec infomation
            txtFirstName.Text       = model.FirstName;
            txtLastName.Text        = model.LastName;
            txtUserName.Text        = model.UserName;
            txtUserName.Text        = model.Email;
            txtTitle.Text           = model.Title;
            txtPhone.Text           = model.Phone;
            txtSkype.Text           = model.Skype;
            ddlStatus.SelectedValue = model.Status;
            InitProjectList();
        }
Beispiel #24
0
        /// <summary>
        /// 向数据表Users更新一条记录。
        /// </summary>
        /// <param name="_UsersModel">_UsersModel</param>
        /// <returns>影响的行数</returns>
        public int Update(UsersEntity _UsersModel)
        {
            string sqlStr = "update Users set [UserCode]=@UserCode,[UserName]=@UserName,[Password]=@Password,[UserType]=@UserType,[Point]=@Point,[Phone]=@Phone,[CreateBy]=@CreateBy,[CreateTime]=@CreateTime,[UpdateTime]=@UpdateTime,[IsActive]=@IsActive,[Memo]=@Memo where Id=@Id";

            SqlParameter[] _param =
            {
                new SqlParameter("@Id",         SqlDbType.BigInt),
                new SqlParameter("@UserCode",   SqlDbType.VarChar),
                new SqlParameter("@UserName",   SqlDbType.VarChar),
                new SqlParameter("@Password",   SqlDbType.VarChar),
                new SqlParameter("@UserType",   SqlDbType.VarChar),
                new SqlParameter("@Point",      SqlDbType.Int),
                new SqlParameter("@Phone",      SqlDbType.VarChar),
                new SqlParameter("@CreateBy",   SqlDbType.VarChar),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@UpdateTime", SqlDbType.DateTime),
                new SqlParameter("@IsActive",   SqlDbType.SmallInt),
                new SqlParameter("@Memo",       SqlDbType.VarChar)
            };
            _param[0].Value  = _UsersModel.Id;
            _param[1].Value  = _UsersModel.UserCode;
            _param[2].Value  = _UsersModel.UserName;
            _param[3].Value  = _UsersModel.Password;
            _param[4].Value  = _UsersModel.UserType;
            _param[5].Value  = _UsersModel.Point;
            _param[6].Value  = _UsersModel.Phone;
            _param[7].Value  = _UsersModel.CreateBy;
            _param[8].Value  = _UsersModel.CreateTime;
            _param[9].Value  = _UsersModel.UpdateTime;
            _param[10].Value = _UsersModel.IsActive;
            _param[11].Value = _UsersModel.Memo;
            return(SqlHelper.ExecuteNonQuery(SqlHelper.Connection, CommandType.Text, sqlStr, _param));
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string msg = CheckInput();

            if (string.IsNullOrEmpty(msg))
            {
                UsersEntity user = GetEntity();
                user.PassWord      = txtNewPsd.Text;
                user.AccountStatus = UsersEntity.ResetPasswordFlag;
                UserApplication userApp = new UserApplication();
                if (userApp.UpdateUser(user))
                {
                    LoginSystem(user, txtNewPsd.Text, true);
                    Response.Redirect("/Default.aspx");
                }
                else
                {
                    ShowMessage(userApp.BrokenRuleMessages[0].Message, false);
                }
            }
            else
            {
                ShowMessage(msg, false);
            }
        }
Beispiel #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDropDownData();
                ListItem liOwner = ddlOwner.Items.FindByValue(Config.SealOwner.ToString());
                if (liOwner == null)
                {
                    UsersEntity usersEntity = userApp.GetUser(Config.SealOwner);
                    ddlOwner.Items.Insert(0, new ListItem()
                    {
                        Value = usersEntity.UserID.ToString(), Text = usersEntity.FirstName
                    });
                }
                else
                {
                    liOwner.Selected = true;
                }

                ListItem liApprover = ddlApprover.Items.FindByValue(Config.SealApprover.ToString());
                if (liApprover == null)
                {
                    UsersEntity usersEntity = userApp.GetUser(Config.SealApprover);
                    ddlApprover.Items.Insert(0, new ListItem()
                    {
                        Value = usersEntity.UserID.ToString(), Text = usersEntity.FirstName
                    });
                }
                else
                {
                    liApprover.Selected = true;
                }
            }
        }
Beispiel #27
0
        private void settingForm_Load(object sender, EventArgs e)
        {
            object value = null;

            try
            {
                UsersEntity entity = new UsersEntity();
                value = UsersBS.loginedUser.Tables[entity.FilledTableName].Rows[0][entity.TableName];
            }
            catch (Exception ex)
            {
            }
            int userype = -1;

            if (value != null)
            {
                userype = int.Parse(value.ToString().Trim());
            }
            if (userype == UsersBS.USER && value != null)
            {
                MessageBox.Show("فقط مدیر سیستم می تواند این فرم را مشاهده کند");
                this.Close();
            }
            loadServerDataFromXMLFile();
            loadPublicSettingToHashTable();
            fillFormOfPubicSetting();

            string time = _applicationPropertiesBL.getValue(ApplicationPropertiesBL.ALARM_LIST_REFRESH_TIME);

            cmbScheduleForRefresh.SelectedValue = time;
        }
Beispiel #28
0
        public List <ReminderModel.ReminderModel> GetReminderTickets(UsersEntity user, DateTime startTime)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT p.ProjectID AS 'ProjectID', p.Title AS 'ProjectName', T.TicketID AS 'TicketId', T.Title AS 'TicketTitle', T.ModifiedOn FROM dbo.Tickets AS T ");
            strSql.Append("LEFT JOIN dbo.Projects AS P ");
            strSql.Append("ON T.ProjectID = P.ProjectID ");
            strSql.Append("WHERE T.Status NOT IN(2, 19, 20) AND T.ResponsibleUser = @ResponsibleUser AND T.ModifiedOn < @QueryDate ");
            strSql.Append("ORDER BY T.ModifiedOn ASC ");

            Database db = DatabaseFactory.CreateDatabase("PM");

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "ResponsibleUser", DbType.Int32, user.UserID);
                db.AddInParameter(dbCommand, "QueryDate", DbType.Date, startTime);

                using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                {
                    List <ReminderModel.ReminderModel> list = new List <ReminderModel.ReminderModel>();
                    while (dataReader.Read())
                    {
                        ReminderModel.ReminderModel ticket = new ReminderModel.ReminderModel();
                        ticket.ProjectId   = dataReader["ProjectId"].ToInt32();
                        ticket.ProjectName = dataReader["ProjectName"].ToString();
                        ticket.TicketId    = dataReader["TicketId"].ToInt32();
                        ticket.TicketTitle = dataReader["TicketTitle"].ToString();
                        ticket.ModifiedOn  = dataReader["ModifiedOn"].ToDateTime();

                        list.Add(ticket);
                    }
                    return(list);
                }
            }
        }
Beispiel #29
0
        private string CheckInput()
        {
            UsersEntity model = UserInfo;
            string      msg   = string.Empty;

            if (model.PassWord != UtilFactory.GetEncryptProvider(EncryptType.MD5).Encrypt(txtOldPassword.Text))
            {
                msg = "The password you gave is incorrect, if you cannot remember you password, please contact the administrator.";
                txtOldPassword.Focus();
            }
            else
            {
                if (string.IsNullOrEmpty(txtPassword.Text))
                {
                    msg = "New password can't be null ";
                    txtPassword.Focus();
                }
                else if (txtPassword.Text != txtConfirmPassword.Text)
                {
                    msg = "Please confirm your new password ";
                    txtConfirmPassword.Focus();
                }
            }
            return(msg);
        }
        public UsersEntity GetUserByUserName(string username)
        {
            string   strSql = @"SELECT  u.*,c.CompanyName
                              FROM [Users] u left join Companys c on u.CompanyID=c.ComID  
                              WHERE UserName =@UserName AND [IsDelete]=0";
            Database db     = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "UserName", DbType.String, username.FilterSqlString());
                UsersEntity model = null;
                using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                {
                    try
                    {
                        if (dataReader.Read())
                        {
                            model = UsersEntity.ReaderBind(dataReader);
                        }
                    }
                    catch (Exception ex)
                    {
                        WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                        strSql.ToString(), base.FormatParameters(dbCommand.Parameters), ex.Message));
                        return(null);
                    }
                }
                return(model);
            }
        }