protected void Page_Load(object sender, EventArgs e) { Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Page.IsPostBack == false) { // First time initialisation. ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); ViewState["TotalHours"] = "0"; this.RowError1.Visible = false; this.RowError2.Visible = false; this.cc2DateSelector.SetDate(DateTime.Now); ShowTeams(); ShowUsers(); ShowGrid(); } this.cc2DateSelector.DateChanged += new KazCustomControls.EventHandler(DateChanged); this.cc2DateSelector.IntervalChanged += new KazCustomControls.EventHandler(IntervalChanged); }
protected void BtnSubmit_Click(object sender, EventArgs e) { // Submit button. try { if ((Util.ReadString("AdminUserName", "") == this.TxtUserName.Text) && (Util.ReadString("AdminPassword", "") == this.TxtPassword.Text)) { // This is the main admin user for the application. FormsAuthentication.RedirectFromLoginPage("0", true); } ClassUser oUsr = new ClassUser(); Int32 UserId = oUsr.Logon(this.TxtUserName.Text, this.TxtPassword.Text); if (UserId > 0) { // We've found the user. FormsAuthentication.RedirectFromLoginPage(UserId.ToString(), true); } // User not found! this.RowMessage.Visible = true; this.LblMsg.Text = "User Not Found!"; } catch (Exception ex) { Log.LogMsg(ex.Message); } }
protected void BtnConfirm_Click(object sender, EventArgs e) { ClassUser oUsr = new ClassUser(); oUsr.Delete(Convert.ToInt32(ViewState["UserId"].ToString())); Response.Redirect("UserMenu.aspx", true); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; ClassUser oUsr = new ClassUser(); this.BtnAddUser.Enabled = true; this.BtnDeleteUser.Enabled = false; this.BtnEditUser.Enabled = false; this.DdlUsers.DataSource = oUsr.ShowUsers(); this.DdlUsers.DataTextField = "UserName"; this.DdlUsers.DataValueField = "UserId"; this.DdlUsers.DataBind(); if (this.DdlUsers.Items.Count > 0) { int UsrId; if (Request.QueryString["UserId"] != null) UsrId = Convert.ToInt32(Request.QueryString["UserId"]); else UsrId = 0; try { this.DdlUsers.SelectedValue = UsrId.ToString(); } catch (Exception) { // Okay to error here. It just means that the user ID doesn't // exist in the dropdown listbox. } this.BtnDeleteUser.Enabled = true; this.BtnEditUser.Enabled = true; } } }
protected void Page_PreInit(object sender, EventArgs e) { // Get user ID and store in ViewState. ViewState["UserId"] = Page.User.Identity.Name.ToString(); if (ViewState["UserId"].ToString() != "0") { ClassUser oUsr = new ClassUser(Convert.ToInt32(Page.User.Identity.Name.ToString())); if ((oUsr.Permissions & (Int32)Enum.Permissions.Report) == 0) { // User isn't allowed to look at reports. Response.Redirect("Default.aspx", false); } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Request.QueryString["UserId"] == null) Response.Redirect("UserMenu.aspx", true); ViewState["UserId"] = Request.QueryString["UserId"].ToString(); ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); this.LblMsg.Text = oUsr.UserName; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { ClassUser oUsr = new ClassUser(); oUsr.TeamId = Convert.ToInt32(this.DdlTeam.SelectedValue); oUsr.UserName = this.TxtUserName.Text; oUsr.Password = this.TxtPassword.Text.Trim(); oUsr.UserGroupId = Convert.ToInt32(this.DdlUserGroup.SelectedValue); oUsr.Surname = this.TxtSurname.Text; oUsr.Forename = this.TxtForename.Text; oUsr.EmailAddress = this.TxtEmailAddress.Text; try { oUsr.HourlyRate = (float) Math.Round(Convert.ToDouble(this.TxtHourlyRate.Text), 2); } catch (Exception) { // User has entered non-numeric text. Default the hourly rate to zero. oUsr.HourlyRate = 0; } oUsr.Save(Convert.ToInt32(ViewState["UserId"])); // Save the assigned projects. ClassProject oPrj = new ClassProject(); oPrj.DeleteMapForUser(oUsr.UserId); foreach (ListItem oLst in this.ClstProjects.Items) { if (oLst.Selected == true) { oPrj.MapProjectToUser(oUsr.UserId, Convert.ToInt32(oLst.Value)); } } Response.Redirect(string.Format("UserMenu.aspx?UserId={0}", oUsr.UserId), true); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); if (((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) == 0) && (ViewState["UserId"].ToString() != "0")) { // User isn't allowed to look at certain managerial reports. this.BtnBudget.Enabled = false; this.BtnCostCentre.Enabled = false; } } }
protected void bt_change_Click(object sender, EventArgs e) { loginUserInfo = (ClassUser)Session["loginUserInfo"]; loginUserInfo.Account = txt_account.Text.ToString(); loginUserInfo.UserName = txt_userName.Text.ToString(); loginUserInfo.Email = txt_email.Text.ToString(); loginUserInfo.Address = txt_address.Text.ToString(); loginUserInfo.PhoneNumber = txt_phoneNumber.Text.ToString(); Dao dao = new Dao(); int result = dao.changeInfo(loginUserInfo); if (result == 1) { lbl_message.Text = "信息修改成功"; lbl_message.Visible = true; } else if (result == 0) { lbl_message.Text = "信息修改失败"; lbl_message.Visible = true; } }
public ClassUser Login(string username, string password) { ClassUser us = new ClassUser(); try { using (var ctx = new GrainContext()) { us = ctx.Database.SqlQuery <ClassUser>("SELECT dbo.[User].UserId, dbo.[User].Name, dbo.[User].CountryId, dbo.[User].UserTypeId, dbo.[User].MailId, dbo.[User].PhoneId " + "FROM dbo.Access LEFT OUTER JOIN dbo.[User] ON dbo.Access.UserId = dbo.[User].UserId " + "WHERE (dbo.Access.passWord = N'" + password + "') AND (dbo.Access.cprNr = N'" + username + "')").FirstOrDefault <ClassUser>(); if (us == null) { us = new ClassUser(); } } } catch (Exception e) { throw e; } return(us); }
protected void Page_Load(object sender, EventArgs e) { Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Page.IsPostBack == false) { // First time initialisation. ClassUser oUsr = new ClassUser(Convert.ToInt32(Page.User.Identity.Name.ToString())); ViewState["TotalHours"] = "0"; this.cc2DateSelector.SetDate(DateTime.Now); ShowGrid(); this.LblProductive.Text = ""; this.LblUnproductive.Text = ""; this.LblProductivePercent.Text = ""; } this.cc2DateSelector.DateChanged += new KazCustomControls.EventHandler(DateChanged); this.cc2DateSelector.IntervalChanged += new KazCustomControls.EventHandler(IntervalChanged); }
//返回一个封装user实体类的list public List <ClassUser> getUserList() { List <ClassUser> userList = new List <ClassUser>(); ClassUser classUser; Dao dao = new Dao(); DataTable userTable = dao.getAllUserTable(); int i = 0; try { while (i < userTable.Rows.Count) { classUser = new ClassUser(); EntityFactory entityFactory = new EntityFactory(); classUser = entityFactory.ToUserClass(userTable, i); i++; userList.Add(classUser); } } catch { } return(userList); }
protected void bt_register_Click(object sender, EventArgs e) { //先验证密码是否一致 if (txt_password.Text == txt_checkCode.Text) { //目前没有对账号的唯一性进行认证,后期再完善 //创建一个用户注册对象 ClassUser registerUserInfo = new ClassUser(); //使用实体工厂将用户注册的信息封装到注册对象当中 EntityFactory entityFactory = new EntityFactory(); int userId = 0;//这里为了满足重载函数要求,初始化为0,但不需要插入数据库,数据库中userId字段为自动增加 string account = this.txt_account.Text.ToString(); string password = this.txt_password.Text.ToString(); string userName = this.txt_userName.Text.ToString(); string email = this.txt_email.Text.ToString(); double moneyLeft = 0;//初始化余额为0 string address = ""; string phoneNumber = ""; registerUserInfo = entityFactory.ToUserClass(userId, account, password, userName, email, moneyLeft, address, phoneNumber);//调用ToUserClass()方法封装信息到实体类 //调用Dao类的注册方法,将实体类信息插入到数据库 Dao dao = new Dao(); int result = dao.register(registerUserInfo); if (result == 1) { Response.Write("<script>alert('注册成功!');top.location='login.aspx' </script>"); } else { Response.Write("<script>alert('注册失败!')</script>"); } } else { txt_checkCode.BorderColor = System.Drawing.Color.Red; } }
public bool AddClassUser(ClassesUserModel model, UserTokenModel curUser) { var exist = db.Set <ClassUser>().FirstOrDefault(t => t.ClassId == model.ClassId && t.UserId == model.UserId && t.IsValid); if (exist != null) { return(true); } var en = new ClassUser { AddUserId = curUser.UserId, EditUserId = curUser.UserId, AddTime = DateTime.Now, EditTime = DateTime.Now, IsValid = true, ClassId = model.ClassId, UserId = model.UserId }; db.Set <ClassUser>().Add(en); db.SaveChanges(); return(true); }
private void btnDisplay_Click(object sender, EventArgs e) { dgvUsers.DataSource = ClassUser.sp_user_display(); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Request.UrlReferrer != null) { ViewState["Referer"] = Request.UrlReferrer.ToString(); } else { ViewState["Referer"] = "Default.aspx"; } Int32 UserId; Int32.TryParse(ViewState["UserId"].ToString(), out UserId); ClassUser oUsr = new ClassUser(UserId); this.TxtUserName.Text = string.Format("{0} {1}", oUsr.Forename, oUsr.Surname); this.TxtEmail.Text = oUsr.EmailAddress; this.TxtUserName.Focus(); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { //ClassTask oTsk = new ClassTask(Convert.ToInt32(this.DdlTasks.SelectedValue)); //Boolean bOkay = false; Boolean bOkay = true; //if ((oTsk.ValidationType & (Int32)Enum.ValidationType.NoValidation) != 0) //{ // // No validation for job reference. User can enter anything // // they like. // bOkay = true; //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.JobMustPreExist) != 0) //{ // // Job must pre-exist and be active in tblJobs. // //ClassJob oJob = new ClassJob(); // //if (oJob.IsJobActive(this.TxtReference.Text) == true) // //{ // // // Job reference is available and is active. // // bOkay = true; // //} // //else // //{ // // // Job reference either doesn't exist or it isn't // // // currently active in tblJobs. // // bOkay = false; // // ShowTimeError("Job reference does not pre-exist!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseRegularExpression) != 0) //{ // // Job reference must meet regular expression. // //System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex(oTsk.ReferenceRegEx); // //if (oReg.IsMatch(this.TxtReference.Text) == true) // //{ // // // Regular expression match is okay. // // bOkay = true; // //} // //else // //{ // // // Regular expression failed. // // bOkay = false; // // ShowTimeError("Job reference failed regular expression check!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseDropDownListBox) != 0) //{ // // Job reference supplied via dropdown listbox. // if (this.DdlJobs.Items.Count > 0) // { // // The user has selected via the dropdown listbox. // //this.TxtReference.Text = this.DdlJobs.SelectedValue; // bOkay = true; // } //} if (bOkay == true) { // We have passed the job reference validation check (if any). ClassTime oTim = new ClassTime(Convert.ToInt32(ViewState["TimeId"].ToString())); ClassUser oUsr = new ClassUser(); oTim.DateVal = this.cc2DateSelector.GetDate(); oTim.UserId = Int32.Parse(ViewState["UserId"].ToString()); oTim.ProjectId = Convert.ToInt32(this.ddlProjects.SelectedValue); //oTim.TaskId = oTsk.TaskId; //oTim.StatusId = Convert.ToInt32(this.ddlStatus.SelectedValue); //oTim.Comment = this.TxtComment.Text; //oTim.JobRef = this.TxtReference.Text; // Check that hours entered is a valid number. System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex("[-+]?[0-9]*\\.?[0-9]+"); if (!oReg.IsMatch(this.txtTotalHours.Text)) { // Regular expression for hours failed. ShowTimeError("The hours entered are incorrectly specified!"); } else { // Hours entered is a valid number. double HoursVal; if (double.TryParse(this.txtTotalHours.Text, out HoursVal) != true) { // Problem with the submitted hours value. ShowTimeError("The hours entered are invalid!"); } else { // Hours value is okay. oTim.Hours = HoursVal; oTim.Save(Int32.Parse(ViewState["TimeId"].ToString())); ShowTime(oTim.TimeId); ShowGrid(0); ViewState["TimeId"] = "0"; //this.TxtComment.Text = ""; this.txtTotalHours.Text = "0.00"; this.LblTimeId.Text = "New"; this.BtnSubmit.Text = "Submit"; ResetTime(); EnableControls(false); BtnSubmit.Enabled = false; } } } //this.DdlProject.Focus(); }
public ObservableCollection <ClassBog> GetAllLentBooks(ClassUser personID) { return(classDbfDB.GetAllLentToUser(personID, "1")); }
private void ShowUsers() { ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); DataSet oDs; Boolean bManager = false; if (((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) != 0) || (ViewState["UserId"].ToString() == "0")) { // Access to management reports allowed. bManager = true; } if (bManager == false) { // This user is restricted to seeing only their own data. oDs = oUsr.ShowUsers2(oUsr.UserId); } else { // This user is allowed to access data for multiple users. oDs = oUsr.ShowUsers1(); } this.DdlUsers.DataSource = oDs; this.DdlUsers.DataTextField = "UserName"; this.DdlUsers.DataValueField = "UserId"; this.DdlUsers.DataBind(); if (bManager == true) { // Access to multiple users allows this user to select all users. this.DdlUsers.Items.Insert(0, new ListItem("All users", "0")); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); if (this.TxtOld.Text.Length > 0) { // User has entered their old password. if (this.TxtOld.Text.Trim() != oUsr.Password) { // Old passwords don't match. this.LblMsg.Text = "Old Password Does Not Match!"; } else if (this.TxtNew1.Text.Trim() != this.TxtNew2.Text.Trim()) { // Both copies of new password are different. this.LblMsg.Text = "New Passwords Do Not Match!"; } else { Boolean bOkay = true; //if (Util.ReadString("PasswordRegExp", "").Length > 0) //{ // // User has to supply a password which meets a regular expression check. // // Regex oReg = new Regex(Util.ReadString("PasswordRegExp", "")); // // bOkay = oReg.IsMatch(this.TxtNew1.Text); //} if (bOkay == true) { oUsr.Surname = this.TxtSurname.Text; oUsr.Forename = this.TxtForename.Text; oUsr.Password = this.TxtNew1.Text.Trim(); oUsr.EmailAddress = this.TxtEmail.Text; oUsr.Save(oUsr.UserId); this.LblMsg.Text = "Updates Applied!"; } else { this.LblMsg.Text = "Password Fails Regular Expression Check!"; } } } else { // User did not enter their old password, so change the email address. oUsr.Surname = this.TxtSurname.Text; oUsr.Forename = this.TxtForename.Text; oUsr.EmailAddress = this.TxtEmail.Text; oUsr.Save(oUsr.UserId); this.LblMsg.Text = "Updates Applied!"; } this.RowMsg1.Visible = true; this.RowMsg2.Visible = true; }
private void DoEnable() { if (ViewState["UserId"].ToString() == "0") { // Super admin has access to everything. } else { // Other users are configured according to their user group permissions. ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); this.BtnGroups.Enabled = false; this.BtnStatus.Enabled = false; if ((oUsr.Permissions & (Int32)Enum.Permissions.Project) == 0) this.BtnProjectAdmin.Enabled = false; if ((oUsr.Permissions & (Int32)Enum.Permissions.Team) == 0) this.BtnTeams.Enabled = false; if ((oUsr.Permissions & (Int32)Enum.Permissions.JobMaintenance) == 0) this.BtnJobs.Enabled = false; if ((oUsr.Permissions & (Int32)Enum.Permissions.Lock) == 0) this.BtnAdminLock.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { ClassUser userLoginInfo = (ClassUser)Session["loginUserInfo"]; Session.Add("userLoginInfo", userLoginInfo); }
protected void Page_PreInit(object sender, EventArgs e) { // Get user ID and store in ViewState. ViewState["UserId"] = Page.User.Identity.Name.ToString(); if (ViewState["UserId"].ToString() == "0") { // Super Admin. ViewState["UserName"] = "******"; } else { ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); if (Util.ReadString("PasswordRegExp", "").Length > 0) { // User has to supply a password which meets a regular expression check. Regex oReg = new Regex(Util.ReadString("PasswordRegExp", "")); if (oReg.IsMatch(oUsr.Password) == false) { // Users password does not meet the regular expression // check that the system admin defined in web.config. // Send the user to the user admin page to force them // to change their password. //Response.Redirect("UserAdmin.aspx", true); } ViewState["UserName"] = string.Format("{0} {1}", oUsr.Forename, oUsr.Surname); } } }
private void DoEnable() { if (ViewState["UserId"].ToString() == "0") { // Super admin has access to everything except user administration. this.RowUserAdmin1.Visible = false; this.RowUserAdmin2.Visible = false; } else { // Other users are configured according to their user group permissions. ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); if ((oUsr.Permissions & (Int32)Enum.Permissions.Administration) == 0) { this.RowConfig1.Visible = false; this.RowConfig2.Visible = false; this.BtnConfig.Enabled = false; this.RowAdmin1.Visible = false; this.RowAdmin2.Visible = false; this.BtnAdminMenu.Enabled = false; } if ((oUsr.Permissions & (Int32)Enum.Permissions.Timesheet) == 0) { this.RowTime1.Visible = false; this.RowTime2.Visible = false; this.BtnTime.Enabled = false; } if ((oUsr.Permissions & (Int32)Enum.Permissions.Report) == 0) { this.RowReports1.Visible = false; this.RowReports2.Visible = false; this.BtnReports.Enabled = false; } } }
public SqlConnections() { ClassOffice o1 = new ClassOffice(); o1.OfficeId = 1; o1.OfficeNumber = 2; ClassOffice o2 = new ClassOffice(); o1.OfficeId = 2; o1.OfficeNumber = 3; listOfOfices = new List <ClassOffice>() { o1, o2 }; ClassDoctor dct1 = new ClassDoctor(); dct1.Active = true; dct1.Doctor_id = 20; dct1.Name = "Jan"; dct1.Surname = "Nowak"; dct1.OfficeNumber = 100; ClassDoctor dct2 = new ClassDoctor(); dct2.Active = true; dct2.Doctor_id = 10; dct2.Name = "Tomasz"; dct2.Surname = "Kowalski"; dct2.OfficeNumber = 200; ListDoctor = new List <ClassDoctor>() { dct1, dct2 }; ClassUser u1 = new ClassUser(); u1.Login = "******"; u1.Password = "******"; u1.Permission = new ClassPermission(); u1.Permission.Permission = "Doctor"; u1.User_id = 1; ClassUser u2 = new ClassUser(); u2.Login = "******"; u2.Password = "******"; u2.Permission = new ClassPermission(); u2.Permission.Permission = "Doctor"; u2.User_id = 2; ClassUser u3 = new ClassUser(); u3.Login = "******"; u3.Password = "******"; u3.Permission = new ClassPermission(); u3.Permission.Permission = "Administrator"; u3.User_id = 3; ListUser = new List <ClassUser>() { u1, u2, u3 }; }
private void ShowUsers() { ClassUser oUsr = new ClassUser(); this.GridUsers.DataSource = oUsr.ShowUsers(); this.GridUsers.DataBind(); }
private void ShowTeams() { ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); ClassTeam oTm = new ClassTeam(); DataSet oDs; Boolean bManager = false; if (((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) == 0) || (ViewState["UserId"].ToString() == "0")) { bManager = true; } if (bManager == false) { // This user is only allowed to access their own team. oDs = oTm.ShowTeams2(oUsr.TeamId); } else { // This user has access to all teams. oDs = oTm.ShowTeams1(); } this.DdlTeams.DataSource = oDs; this.DdlTeams.DataTextField = "TeamName"; this.DdlTeams.DataValueField = "TeamId"; this.DdlTeams.DataBind(); }
private void txtsearch_TextChanged(object sender, EventArgs e) { dgvUsers.DataSource = ClassUser.sp_user_search(txtsearch.Text); }
/// <summary> /// Kalder til en metode i ClassPurchaseDB, der checker om der er indtastet korrekt brugernavn og adgangskode, og derefter henter brugeren /// </summary> /// <returns></returns> public ClassUser GetUserData() { return(CU = CPDB.GetUser(cprNr, passWord)); }
bool ITaskOrganizer.ConfirmUser(User user) { return(ClassUser.ConfirmUser(user)); }
public void LendThisBookToTheUser(ClassBog lentBook, ClassUser user) { }
public bool AddUser(User user) { return(ClassUser.RegistrationUser(user)); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Request.QueryString["UserId"] == null) Response.Redirect("UserMenu.aspx", true); ViewState["UserId"] = Request.QueryString["UserId"].ToString(); ClassTeam oTm = new ClassTeam(); this.DdlTeam.DataSource = oTm.ShowTeams1(); this.DdlTeam.DataTextField = "TeamName"; this.DdlTeam.DataValueField = "TeamId"; this.DdlTeam.DataBind(); this.DdlTeam.Items.Insert(0, new ListItem("-- Choose team --", "0")); ClassUser oUsr = new ClassUser(Convert.ToInt32(Request.QueryString["UserId"])); this.TxtUserName.Text = oUsr.UserName; string TxtStr = oUsr.Password; if (TxtStr.Length < 8) TxtStr = TxtStr.PadRight(8); this.TxtPassword.Text = TxtStr; this.TxtPassword.TextMode = TextBoxMode.Password; this.TxtPassword.Attributes.Add("value", TxtStr); this.TxtSurname.Text = oUsr.Surname; this.TxtForename.Text = oUsr.Forename; this.TxtEmailAddress.Text = oUsr.EmailAddress; this.TxtHourlyRate.Text = string.Format("{0:f}", oUsr.HourlyRate); ClassUserGroup oGrp = new ClassUserGroup(); this.DdlUserGroup.DataSource = oGrp.ShowUserGroups(); this.DdlUserGroup.DataTextField = "UserGroupName"; this.DdlUserGroup.DataValueField = "UserGroupId"; this.DdlUserGroup.DataBind(); this.DdlUserGroup.Items.Insert(0, new ListItem("-- Choose user group --", "0")); try { this.DdlTeam.SelectedValue = oUsr.TeamId.ToString(); } catch (Exception) { // Do nothing - we don't need to worry about a team which // can't be selected. } try { this.DdlUserGroup.SelectedValue = oUsr.UserGroupId.ToString(); } catch (Exception) { // Okay to error. The supplied user group id isn't in the // dropdown listbox. } ClassProject oPrj = new ClassProject(); DataSet oDs = oPrj.ShowProjectsWithUserMap(oUsr.UserId); this.ClstProjects.DataSource = oDs; this.ClstProjects.DataTextField = "ProjectName"; this.ClstProjects.DataValueField = "ProjectId"; this.ClstProjects.DataBind(); foreach (DataRow oDr in oDs.Tables[0].Rows) { if (Convert.ToInt32(oDr["Selected"].ToString()) != 0) { ListItem oChk = this.ClstProjects.Items.FindByValue(oDr["ProjectId"].ToString()); if (oChk != null) { oChk.Selected = true; } } } this.TxtUserName.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Page.IsPostBack == false) { // First time initialisation. ViewState["TimeId"] = "0"; ViewState["Interval"] = "W"; ViewState["TotalHours"] = "0"; ShowProjects(); ShowStatus(); CheckReady(); this.LblTimeId.Text = "New"; this.BtnSubmit.Text = "Submit"; ViewState["GridPage"] = "20"; ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); if ((oUsr.Permissions & (Int32)Enum.Permissions.JobMaintenance) == 0) { // User cannot perform job maintenance. this.RowJob1.Visible = false; this.RowJob2.Visible = false; } else { // User can perform job maintenance. this.RowJob1.Visible = true; this.RowJob2.Visible = true; } if (ViewState["UserId"].ToString() == "0") { // System administrator cannot enter timesheets! this.RowAdmin1.Visible = true; this.RowAdmin2.Visible = true; } Int32 PageSize; PageSize = Convert.ToInt32(ViewState["GridPage"].ToString()); PageSize = (PageSize < 5) ? 5 : PageSize; this.GridTime.PageSize = PageSize; ViewState["GridPage"] = PageSize.ToString(); this.cc2DateSelector.SetDate(DateTime.Now); ShowGrid(0); this.ddlProjects.Focus(); EnableControls(false); } this.cc2DateSelector.DateChanged += new KazCustomControls.EventHandler(DateChanged); this.cc2DateSelector.IntervalChanged += new KazCustomControls.EventHandler(IntervalChanged); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); this.TxtSurname.Text = oUsr.Surname; this.TxtForename.Text = oUsr.Forename; this.TxtEmail.Text = oUsr.EmailAddress; this.TxtSurname.Focus(); } }
private void ShowUsers() { ClassUser oUsr = new ClassUser(Convert.ToInt32(ViewState["UserId"].ToString())); DataSet oDs; if ((oUsr.Permissions & (Int32)Enum.Permissions.ManagerOnly) == 0) { // This user is restricted to seeing only their own data. if (ViewState["UserId"].ToString() != "0") { oDs = oUsr.ShowUsers2(oUsr.UserId); } else { // Except this is the superuser, who can see everything. oDs = oUsr.ShowUsers1(); } } else { // This user is allowed to access data for multiple users. oDs = oUsr.ShowUsers1(); } this.DdlUsers.DataSource = oDs; this.DdlUsers.DataTextField = "UserName"; this.DdlUsers.DataValueField = "UserId"; this.DdlUsers.DataBind(); }
public void UpdateRentStatus(ClassBog inBook, ClassUser inPerson) { ExecuteNonQuery($"UPDATE Udlaan SET udlaansStatus = {inBook.rentdate.udlaanstatus}, udlaansDato = {inBook.rentdate.strUdlaansDate}, personID = {inPerson.id}, bookID = {inBook.id}"); }
private Int32 GetUserId(string UsrNam, string UsrPwd) { Int32 RetVal = 0; try { ClassUser oUsr = new ClassUser(); RetVal = oUsr.Logon(UsrNam,UsrPwd); } catch (Exception ex) { Log.LogMsg(ex.Message); RetVal = -1; } return RetVal; }
public Airport(MainWindow main) { MyScheduledFlights = new ObservableCollection <ClassScheduledFlight>(); MySimFlights = new ObservableCollection <ClassScheduledFlight>(); MyMain = main; MyManager = main.Manager; MyUtil = new ClassUser(); MyUtil = main.Uti; InitializeComponent(); Stack_ScheduledFlights.Visibility = Visibility.Visible; // on s'assure d'etre sur le bon affichage Stack_sim.Visibility = Visibility.Collapsed; DataContext = MyUtil; Datagrid_Flights.DataContext = MyScheduledFlights; ObservableCollection <ClassScheduledFlight> flight = new ObservableCollection <ClassScheduledFlight>(); try { flight = ClassSerializable.LoadFromXMLFormat <ClassScheduledFlight>(MyManager.WorkPlace + "/" + MyUtil.Code + "_FlightS.xml"); foreach (ClassScheduledFlight item in flight) { MyScheduledFlights.Add(item); } Sort(); List <ClassScheduledFlight> temp = new List <ClassScheduledFlight>(); foreach (ClassScheduledFlight item in MyScheduledFlights) { if (item.Flight.Source == null) { item.Flight.Source = MyUtil.Code; } else if (!item.Flight.Source.Equals(MyUtil.Code)) { temp.Add(item); } } foreach (ClassScheduledFlight item in temp) { MyScheduledFlights.Remove(item); } if (MyScheduledFlights.Count == 0) { MessageBox.Show("No scheduled flight found for this company !", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } Datagrid_Flights.DataContext = MyScheduledFlights; } catch (Exception) { MessageBox.Show("File doesn't exists - File creation !", "Error", MessageBoxButton.OK, MessageBoxImage.Error); ClassSerializable.SaveAsXMLFormat(MyScheduledFlights, MyManager.WorkPlace + "/" + MyUtil.Code + "_FlightS.xml"); } Closing += Closing_Airport; Pause = false; ButtonStart.IsEnabled = true; ButtonStop.IsEnabled = false; ButtonPause.IsEnabled = false; }
public async Task <IActionResult> EnrollInClass([FromBody] ClassUser classUser, [FromQuery] string action, [FromQuery] string userId) { var lang = Request.Headers["language"].ToString(); var errorMessages = new List <string>(); try { if (string.IsNullOrEmpty(classUser.ClassId) || classUser.UserId == null) { errorMessages.Add(_translator.GetTranslation("ERROR", lang)); return(BadRequest(new { errors = errorMessages })); } var cls = _classRepository.FindById(classUser.ClassId); var member = await _userManager.FindByIdAsync(classUser.UserId); if (cls == null || member == null) { errorMessages.Add(_translator.GetTranslation("ERROR", lang)); return(BadRequest(new { errors = errorMessages })); } if (action == "enroll") { var newClassUser = new ClassUser() { Class = cls, ClassId = classUser.ClassId, User = member, UserId = classUser.UserId, EnrollDateTime = DateTime.Now }; cls.ClassUsers.Add(newClassUser); } else if (action == "disenroll") { var enrollement = cls.ClassUsers .SingleOrDefault(e => e.ClassId == classUser.ClassId && e.UserId == classUser.UserId); _doneSessionRepository.DeleteAllByCourseUser(cls.Course.Id, classUser.UserId); cls.ClassUsers.Remove(enrollement); } var updatedClass = _classRepository.Update(cls); if (updatedClass != null) { if (action == "enroll") { await _notificationRepository.Create(new Notification() { Type = "ENROLLEMENT", Text = $"{member.FirstName} {member.LastName} enrolled in class [ {cls.Name_EN} ]", DateTime = DateTime.Now, Info = null, IsSeen = false, }); } else if (action == "disenroll") { await _notificationRepository.Create(new Notification() { Type = "ENROLLEMENT", Text = $"{member.FirstName} {member.LastName} disenrolled from class [ {cls.Name_EN} ]", DateTime = DateTime.Now, Info = null, IsSeen = false, }); } } var user = await _userManager.FindByIdAsync(userId); bool isAdmin = false; if (user != null) { isAdmin = user.IsAdmin && (await _userManager.IsInRoleAsync(user, "Admin")); } return(Ok(new { updatedClass = ResponseGenerator.GenerateClassResponse(cls, isAdmin) })); } catch { errorMessages.Add(_translator.GetTranslation("ERROR", lang)); return(BadRequest(new { errors = errorMessages })); } }