protected void lbtnReport_Click(object sender, EventArgs e) { LinkButton lbtn = (LinkButton)sender; GridViewRow gvr = (GridViewRow)lbtn.NamingContainer; int i = Convert.ToInt32(gvr.RowIndex); BloodPlateletRequestUser selectedRequest = userRequests[gvRequestInfo.PageSize * gvRequestInfo.PageIndex + gvRequestInfo.SelectedIndex]; List <BplTransactionUserToUser> allUserTransactions = BplTransactionUserToUserDB.getAllbpTransUserToUser(); foreach (BplTransactionUserToUser m in allUserTransactions) { if (m.bpMatchUsrUsr.bplUsrRequestID.bplUserRequestID == selectedRequest.bplUserRequestID && m.status == "accepted") { usersAccepted.Add(m); } } BplTransactionUserToUser selectedTransaction = usersAccepted[i]; Users reportedUser = selectedTransaction.bpMatchUsrUsr.matchID; reportedUser.MedicalStatus = "cannot donate"; reportedUser.MedicalStatusUpdateBy = ((Establishment)Session["establishment"]).ID; UsersDB.updateUser(reportedUser); List <LastDonationDate> allLastDates = LastDonationDateDB.getAllLastDonations(); foreach (LastDonationDate ld in allLastDates) { if (ld.User.UserId == reportedUser.userId) { ld.LastDonation = DateTime.Today; ld.Type = selectedRequest.bloodOrPlatelet; ld.Status = "Not in transaction"; LastDonationDateDB.updateLastDonation(ld); } } selectedTransaction.status = "cancelled"; BplTransactionUserToUserDB.updateBPTranscationUserToUser(selectedTransaction); selectedTransaction.bpMatchUsrUsr.status = "declined"; BPMatchUserToUserDB.updateMatchUserToUser(selectedTransaction.bpMatchUsrUsr); selectedRequest.unitMatched = selectedRequest.unitMatched - selectedTransaction.unitsPossible; BloodPlateletRequestUserDB.updateBloodPlateles(selectedRequest); Server.Transfer("UserDonations.aspx"); }
/// <summary> /// The BindData helper method is used to bind the list of /// security roles for this portal to an asp:datalist server control /// </summary> private void BindData() { // Bind the Email and Password UsersDB users = new UsersDB(); Guid currentUserID = this.userID;// PortalSettings.CurrentUser.Identity.ProviderUserKey; // bind users in role to DataList IList <AppleseedRole> roles = new List <AppleseedRole>(); try { roles = users.GetRolesByUser(currentUserID, this.PortalSettings.PortalAlias); } catch (Exception exc) { ErrorHandler.Publish(LogLevel.Error, exc); } userRoles.DataKeyField = "Id"; userRoles.DataSource = roles; userRoles.DataBind(); // bind all portal roles to dropdownlist IList <AppleseedRole> allRolesList = users.GetPortalRoles(this.PortalSettings.PortalAlias); // remove "All Users", "Authenticated Users" and "Unauthenticated Users" pseudo-roles AppleseedRole pseudoRole = new AppleseedRole(AppleseedRoleProvider.AllUsersGuid, AppleseedRoleProvider.AllUsersRoleName); if (allRolesList.Contains(pseudoRole)) { allRolesList.Remove(pseudoRole); } pseudoRole = new AppleseedRole(AppleseedRoleProvider.AuthenticatedUsersGuid, AppleseedRoleProvider.AuthenticatedUsersRoleName); if (allRolesList.Contains(pseudoRole)) { allRolesList.Remove(pseudoRole); } pseudoRole = new AppleseedRole(AppleseedRoleProvider.UnauthenticatedUsersGuid, AppleseedRoleProvider.UnauthenticatedUsersRoleName); if (allRolesList.Contains(pseudoRole)) { allRolesList.Remove(pseudoRole); } allRoles.DataSource = allRolesList; allRoles.DataBind(); }
private void ViewUser(int rowIndex) { int? intKey = null; DataRow row = dataTableUser.Rows[rowIndex]; if (row != null) { int outIntKey; if (int.TryParse(row.ItemArray[0].ToString(), out outIntKey)) { intKey = outIntKey; } } FormUser frm = new FormUser(intKey); frm.ShowDialog(); LoadGridUtenze(UsersDB.SetQueryUser(string.Empty)); }
public ActionResult viewUsers() { var data = UsersDB.loadUsers(); List <UsersModel> users = new List <UsersModel>(); foreach (var el in data) { users.Add(new UsersModel { age = el.age, name = el.name, surname = el.surname, email = el.email, password = el.password }); } return(View(users)); }
public Task <DataResponse <User> > AddUserAsync(BasicRegisterRequest request) { var user = new User { Name = request.Name, Credentials = new Credentials { Pitz = new PitzCredentials { Email = request.Email, Password = request.Password } } }; UsersDB.Add(user); return(Task.FromResult(new DataResponse <User>(true, user))); }
// POST api/values /// <summary> /// Authentication /// </summary> /// <param name="value"></param> /// <returns></returns> public IHttpActionResult Post([FromBody] User value) { try { User checkIfUserExist = UsersDB.GetUserByEmailAndPassword(value.email, value.password); if (checkIfUserExist == null) { return(Content(HttpStatusCode.BadRequest, $"user with id = {value.email} not exist")); } else { return(Content(HttpStatusCode.OK, checkIfUserExist)); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static void SendMessage(string msg, string username) { if (string.IsNullOrEmpty(msg) || msg.Count(c => c == ' ') == msg.Length || msg.Count(c => c == '\n') == msg.Length) { return; } using (UsersDB db = new UsersDB()) { User user = db.Users.SingleOrDefault(u => u.Username == username); db.Messages.Add(new Message { UserID = user.ID, Text = msg, Username = user.Username }); db.SaveChanges(); } }
protected void BtnSentMessage_Click1(object sender, EventArgs e) { if (Session["chat"] != null) { Users s = UsersDB.getUserbyEmail(Session["email"].ToString()); Users r = UsersDB.getUserbyUsername(lblName.Text); IndividualChatRoom icr = new IndividualChatRoom(s.UserId, r.UserId, System.DateTime.Now, TextBox1.Text); IndividualChatRoomDB.insertIndChat(icr); } else { string eID = Session["echat"].ToString(); Users s = UsersDB.getUserbyEmail(Session["email"].ToString()); Establishment r = EstablishmentDB.getEstablishmentByID(eID); IndividualChatRoom icr = new IndividualChatRoom(s.UserId, r.ID, System.DateTime.Now, TextBox1.Text); IndividualChatRoomDB.insertIndChat(icr); } TextBox1.Text = ""; UpdatePanel1.Update(); }
/// <summary> /// The usersInRole_ItemCommand server event handler on this page /// is used to handle the user editing and deleting roles /// from the usersInRole asp:datalist control /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs"/> instance containing the event data.</param> protected void usersInRole_ItemCommand(object sender, DataListCommandEventArgs e) { UsersDB users = new UsersDB(); Label lblUserEmail = (Label)e.Item.FindControl("lblUserEmail"); RainbowUser user = ( RainbowUser )Membership.GetUser(lblUserEmail.Text); if (e.CommandName == "delete") { // update database users.DeleteUserRole(roleId, user.ProviderUserKey); // Ensure that item is not editable usersInRole.EditItemIndex = -1; // Repopulate list BindData(); } }
/// <summary> /// The usersInRole_ItemCommand server event handler on this page /// is used to handle the user editing and deleting roles /// from the usersInRole asp:datalist control /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataListCommandEventArgs"/> instance containing the event data.</param> protected void usersInRole_ItemCommand(object sender, DataListCommandEventArgs e) { UsersDB users = new UsersDB(); Label lblUserEmail = (Label)e.Item.FindControl("lblUserEmail"); string userName = Membership.GetUserNameByEmail(lblUserEmail.Text); AppleseedUser user = (AppleseedUser)Membership.GetUser(userName); if (e.CommandName == "delete") { // update database users.DeleteUserRole(roleId, user.ProviderUserKey, this.PortalSettings.PortalAlias); // Ensure that item is not editable usersInRole.EditItemIndex = -1; // Repopulate list BindData(); } }
/// <summary> /// The BindData helper method is used to bind the list of /// security roles for this portal to an asp:datalist server control /// </summary> private void BindData() { // Bind the Email and Password UsersDB users = new UsersDB(); // SqlDataReader dr = users.GetSingleUser(userName, portalSettings.PortalID); // bind users in role to DataList SqlDataReader drUsers = users.GetRolesByUser(userName, portalSettings.PortalID); userRoles.DataSource = drUsers; userRoles.DataBind(); drUsers.Close(); //by Manu, fixed bug 807858 // bind all portal roles to dropdownlist SqlDataReader drRoles = users.GetPortalRoles(portalSettings.PortalID); allRoles.DataSource = drRoles; allRoles.DataBind(); drRoles.Close(); //by Manu, fixed bug 807858 }
public static PASSPORTSCAN Save(PASSPORTSCAN entity) { if (entity == null) { return(null); } try { var righeReservation = new List <RESERVATION>(); var righeGuests = new List <Guests>(); var righeUsers = new List <Users>(); foreach (var datiReservation in entity.RESERVATION) { righeReservation.Add(datiReservation); } SaveReservation(righeReservation); foreach (var datiGuest in entity.Guests) { righeGuests.Add(datiGuest); Users utente = new Users(); utente.NOME = datiGuest.FirstName; utente.COGNOME = datiGuest.LastName; utente.DTINS = DateTime.Now; utente.MAIL = datiGuest.EMail; utente.STRADA = datiGuest.Address1; utente.DTNAS = DateTime.ParseExact(datiGuest.BirthDate, "yyyyMMdd", CultureInfo.InvariantCulture); utente.KEY_NAZ_NAS = IndirizzoDB.LoadNazione(null, (datiGuest.BirthNation + "*")).ID; righeUsers.Add(utente); } SaveGuest(righeGuests); UsersDB.SaveListUsers(righeUsers); } catch (Exception e) { throw e; } return(entity); }
private void LoadGridUtenze() { try { dataTable = new DataTable(); dataTable = UsersDB.LoadUser(string.Empty); dataGridView1.Rows.Clear(); dataGridView1.ReadOnly = true; dataGridView1.Columns[0].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView1.Columns[1].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView1.Columns[2].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView1.Columns[3].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView1.Columns[4].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); foreach (DataRow item in dataTable.Rows) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = item[1].ToString(); dataGridView1.Rows[n].Cells[1].Value = item[2].ToString(); if (!string.IsNullOrEmpty(item[4].ToString())) { dataGridView1.Rows[n].Cells[2].Value = DateTime.ParseExact(item[4].ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); dataGridView1.Rows[n].Cells[2].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows[n].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } dataGridView1.Rows[n].Cells[3].Value = item[15].ToString() + " " + item[16].ToString() + " " + item[17].ToString(); dataGridView1.Rows[n].Cells[4].Value = DateTime.ParseExact(item[3].ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); dataGridView1.Rows[n].Cells[4].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows[n].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } dataGridView1.Rows[dataTable.Rows.Count].Cells[0].Value = "Aggiungi Utenza"; } catch (Exception ex) { MessageBox.Show("Errore caricamento griglia utenze: " + ex.Message); } }
public IHttpActionResult Post([FromBody] User user2Insert) { try { User checkIfUserExist = UsersDB.GetUserByEmail(user2Insert.email); if (checkIfUserExist == null) { int res = UsersDB.InsertUser(user2Insert); if (res == 0) { return(Content(HttpStatusCode.BadRequest, $"user with id = {user2Insert.email} was not created in DB!!!")); } return(Created(new Uri(Request.RequestUri.AbsoluteUri + res), user2Insert)); } return(Content(HttpStatusCode.BadRequest, $"user exist in DB!!!")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private void DeleteUser(int rowIndex) { int? intKey = null; DataRow row = dataTableUser.Rows[rowIndex]; if (row != null) { if (DialogResult.No == MessageBox.Show(("Verrà eliminata l'utenza selezionata. Vuoi proseguire ?"), "Elimina Utenza", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } int outIntKey; if (int.TryParse(row.ItemArray[0].ToString(), out outIntKey)) { intKey = outIntKey; UsersDB.DeleteUser(outIntKey); LoadGridUtenze(UsersDB.SetQueryUser(string.Empty)); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["email"] == null) { Button1.Enabled = true; } else { Button1.Enabled = false; } int num = 0, esnum = 0, btc = 0, numo = 0; List <Users> userslist = UsersDB.getallUsers(); num = userslist.Count; lblTotalUsers.Text = num.ToString(); lblOutput.Text = ""; List <Establishment> estlist = EstablishmentDB.getAllEstablishments(); esnum = estlist.Count; lblTotalAssociates.Text = esnum.ToString(); List <GReportBloodPlatelet> listEE = GReportBloodPlateletDB.HgetAllBloodEToE(); List <GReportBloodPlatelet> listEU = GReportBloodPlateletDB.HgetAllBloodEToU(); List <GReportBloodPlatelet> listUE = GReportBloodPlateletDB.HgetAllBloodUToE(); List <GReportBloodPlatelet> listUU = GReportBloodPlateletDB.HgetAllBloodUToU(); btc = listEE.Count + listEU.Count + listUE.Count + listUU.Count; lblSuccessfulBloodDonation.Text = btc.ToString(); List <OrganRecipient> orlist = OrganRecipientDB.getAllRecipients(); foreach (OrganRecipient o in orlist) { if (o.Status == "complete") { numo++; } } lblOrganDonation.Text = numo.ToString(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string username = Session["username"].ToString(); Users euser = UsersDB.getUserbyUsername(username); euser.emergencyname = tbxEName.Text; euser.emergencyphone = Convert.ToInt32(tbxEPhone.Text); euser.emergencyrelationship = ddlRelation.SelectedItem.Text; int num = UsersDB.updateEmergencyUser(euser); if (num != 1) { lblOutput.Text = "Cannot Register Emergency Contact!"; } else { lblOutput.Text = "Successful! Emergency contact is added to your account."; //auto redirect to the same page in 2 sec string MyAccountUrl = "MyAccount.aspx"; Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl))); } }
/// <summary> /// The BindData helper method is used to bind the list of /// security roles for this portal to an asp:datalist server control /// </summary> private void BindData() { // add the role name to the title if (roleId != Guid.Empty) { AppleseedRoleProvider roleProvider = (AppleseedRoleProvider)System.Web.Security.Roles.Provider; AppleseedRole role = roleProvider.GetRoleById(roleId); title.InnerText = General.GetString("ROLE_MEMBERSHIP") + role.Name; } // Get the portal's roles from the database UsersDB users = new UsersDB(); // bind users in role to DataList usersInRole.DataSource = users.GetRoleMembers(roleId, this.PortalSettings.PortalAlias); usersInRole.DataBind(); // bind all portal users to dropdownlist allUsers.DataSource = users.GetUsers(this.PortalSettings.PortalAlias); allUsers.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string nemail = Session["email"].ToString(); Users now = UsersDB.getUserbyEmail(nemail); string np = tbxnewPass.Text; string np2 = tbxnewPassRepeat.Text; if (now.password != tbxCurrentPsw.Text) { lblCP.Visible = true; return; } else { lblCP.Visible = false; if (np == np2) { now.password = np; int num = UsersDB.updateUser(now); if (num != 1) { lblOutput.Text = "Cannot Change Password!"; } else { lblOutput.Text = "Password Updated!"; //auto refresh the page string MyAccountUrl = "MyAccount.aspx"; Page.Header.Controls.Add(new LiteralControl(string.Format(@" <META http-equiv='REFRESH' content=2;url={0}> ", MyAccountUrl))); } } else { lblOutput.Text = "New password and repeat password is not matching!"; tbxnewPassRepeat.Text = ""; tbxnewPass.Text = ""; } } }
public IHttpActionResult Post([FromBody] Bussiness bussiness2Insert) { try { User u = UsersDB.GetUserByEmail(bussiness2Insert.userEmail); if (u != null) { int res = BussinessDB.InsertBussiness(bussiness2Insert); if (res == -1) { return(Content(HttpStatusCode.BadRequest, $"bussiness with id = {bussiness2Insert.Bussiness_Id} was not created in DB!!!")); } bussiness2Insert.Bussiness_Id = res; return(Created(new Uri(Request.RequestUri.AbsoluteUri + res), bussiness2Insert)); } return(Content(HttpStatusCode.BadRequest, $"user not exist")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
protected void getData() { DataAccess da = new DataAccess(); UsersDB users = new UsersDB(); SqlDataReader drUser = users.GetSingleUser(Context.User.Identity.Name); if (drUser.HasRows) { drUser.Read(); //prssID = (int)drUser["PRSS"]; userid = (int)drUser["UserId"]; LoginName = drUser["LoginName"].ToString(); } SqlDataReader drFromDatabase = da.GetPDF(hourlyApplicationID); if (!drFromDatabase.HasRows) { return; } fillPageFromDataReader(drFromDatabase); }
public static List <GReportBloodPlatelet> getAllBloodUToUWTime(string ID) { List <GReportBloodPlatelet> utoelists = new List <GReportBloodPlatelet>(); try { SqlCommand command = new SqlCommand("select bpr.bplUserRequestID , bpr.requestorID,bpr.bloodGroup,bpr.bloodOrPlatelet, bpr.unitsRequird,uu.matchID,bpr.requestDate,bpr.establishmentID, tuu.status from BloodPlateletRequestUser bpr, BPMatchUserToUser uu, BplTransactionUserToUser tuu where bpr.bplUserRequestID = uu.bplUserRequestID and uu.bpMatchUsrUsr = tuu.bpMatchUsrUsr and bpr.establishmentID=@ID and tuu.status='complete'"); command.Parameters.AddWithValue("@ID", ID); command.Connection = connection; connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { GReportBloodPlatelet fu = new GReportBloodPlatelet(); fu.ID = reader["bplUserRequestID"].ToString(); Users u = UsersDB.getUserbyID(reader["requestorID"].ToString()); fu.Requestor = u.name; fu.BloodGroup = reader["bloodGroup"].ToString(); fu.BloodOrPlatelet = reader["bloodOrPlatelet"].ToString(); fu.UnitRequire = reader["unitsRequird"].ToString(); Users u2 = UsersDB.getUserbyID(reader["matchID"].ToString()); fu.Giver = u2.Name; fu.GivenUnit = "1"; fu.Date = Convert.ToDateTime(reader["requestDate"]); Establishment es = EstablishmentDB.getEstablishmentByID(reader["establishmentID"].ToString()); fu.Status = es.Name; utoelists.Add(fu); } reader.Close(); } finally { connection.Close(); } return(utoelists); }
public static List <GReportBloodPlatelet> getAllBloodEToU(DateTime from, DateTime to) { List <GReportBloodPlatelet> utoelists = new List <GReportBloodPlatelet>(); try { SqlCommand command = new SqlCommand("select bpr.bplEstabRequestID , bpr.establishmentID,bpr.bloodGroup,bpr.bloodOrPlatelet, bpr.unitsRequired,uu.matchID,tuu.unitsPossible,bpr.requestDate,tuu.status from BloodPlateletRequestEstab bpr, BPMatchEstabToUser uu, BplTransactionEstabToUser tuu where bpr.bplEstabRequestID = uu.bplEstabRequestID and uu.bpMatchEstabUserID = tuu.bpMatchEstabUserID and requestDate between @from AND @to"); command.Parameters.AddWithValue("@from", from); command.Parameters.AddWithValue("@to", to); command.Connection = connection; connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { GReportBloodPlatelet fu = new GReportBloodPlatelet(); fu.ID = reader["bplEstabRequestID"].ToString(); Establishment es = EstablishmentDB.getEstablishmentByID(reader["establishmentID"].ToString()); fu.Requestor = es.Name; fu.BloodGroup = reader["bloodGroup"].ToString(); fu.BloodOrPlatelet = reader["bloodOrPlatelet"].ToString(); fu.UnitRequire = reader["unitsRequired"].ToString(); Users u2 = UsersDB.getUserbyID(reader["matchID"].ToString()); fu.Giver = u2.Name; fu.GivenUnit = reader["unitsPossible"].ToString(); fu.Date = Convert.ToDateTime(reader["requestDate"]); fu.Status = reader["status"].ToString(); utoelists.Add(fu); } reader.Close(); } finally { connection.Close(); } return(utoelists); }
private void txtFilter_KeyUp(object sender, KeyEventArgs e) { if (bFreeze) { return; } string strFilter = ""; if (cmbFilter.SelectedIndex == 3) { if (DateTime.TryParseExact(txtFilter.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result)) { if (cmbTime.SelectedIndex == 0) { MessageBox.Show("Impostare il riferimento (<,>,=)", "Riferimento", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } validDate = true; strFilter = sFilter + " AND '" + DateTime.ParseExact(txtFilter.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd") + "'" + ((KeyValuePair <string, string>)cmbTime.SelectedItem).Value + " DTINS "; } else { return; } } else { if (string.IsNullOrEmpty(txtFilter.Text)) { return; } strFilter = sFilter + " AND " + ((KeyValuePair <string, string>)cmbFilter.SelectedItem).Value + " LIKE '" + txtFilter.Text + "%'"; } LoadGridUtenze(UsersDB.SetQueryUser(strFilter)); }
// // GET: /Users/Details/5 public ActionResult Details(int id = 0) { dynamic obj; UsersDB usersdb = db.Users.Find(id); if (usersdb == null) { return(HttpNotFound()); } else { WebClient jsonClient = new WebClient(); string jsonDataStr = jsonClient.DownloadString( "https://bftjuniorapi20160519024425.azurewebsites.net/api/test"); JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); obj = jsonSerializer.Deserialize <object>(jsonDataStr); // We will randomize the tweet output Random r = new Random(); int nTweets = r.Next(1, 6); var uniqueNums = Enumerable.Range(0, 5) .OrderBy(x => r.Next()) .Take(nTweets) .Distinct() .ToList(); List <string> _tweets = new List <string>(); for (int i = 0; i < uniqueNums.Count; ++i) { _tweets.Add(obj[uniqueNums.ElementAt(i)]["text"]); } ViewBag.Tweets = _tweets; } return(View(usersdb)); }
protected void Button1_Click(object sender, EventArgs e) { if (email.Text != "" && password.Text != "") { String pass = UsersDB.userLogin(email.Text, password.Text); if (pass.Equals("empty")) { Label1.Text = "Ky email nuk eshte i konfirmuar si admin"; } else if (pass.Equals("found")) { Label1.Text = "Welcome we are currently fixing this page thank you for visiting!"; Session["id"] = UsersDB.userId(email.Text); Session["sessionValue"] = "set"; Session["email"] = email.Text; Session["company"] = UsersDB.userType(email.Text); Session["admin"] = UsersDB.admin(email.Text); Response.Redirect("AdminPage.aspx"); //check if a company is logged in and redirect it to its profile otherwise redirect the normal user //i ke te gjitha gati vetem shiko pse nuk punon if //Server.Transfer("profile.aspx", true); } else if (pass.Equals("wrong")) { Label1.Text = "Wrong password m**********r"; } } else { Label1.Text = "*Duhet te plotesoni te gjitha fushat"; } }
private void btnAddUtenzeFromFile_Click(object sender, EventArgs e) { if (DialogResult.No == MessageBox.Show(string.Format("Verrà acquisito un file xml per l'importazione delle utenze." + Environment.NewLine + "Vuoi proseguire?", ""), "Acquisizione File", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } string filePath; filePath = FileService.CaricaFile("xml", "XML files (*.xml)|*.xml|All files (*.*)|*.*"); if (!File.Exists(filePath)) { MessageBox.Show("Impossibile trovare il file nella posizione indicata.", "File non trovato", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TemplateXmlDB.Exists(filePath)) { MessageBox.Show("Il file risulta già importato.", "File già presente", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { FileService.AcquireXML(new StreamReader(filePath), filePath); MessageBox.Show("File correttamente acquisito.", "Acquisizione File", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGridUtenze(UsersDB.SetQueryUser(string.Empty)); } catch (Exception ex) { MessageBox.Show("Errore: " + ex.Message, "Errore Importazione", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName, string portalPath) { int newPortalID; PortalsDB portals = new PortalsDB(); TabsDB tabs = new TabsDB(); ModulesDB modules = new ModulesDB(); UsersDB users = new UsersDB(); // create an Array to stores modules ID and GUID for finding them later ArrayList templateModules = new ArrayList(); moduleTemplate module; // create an Array to stores tabs ID for finding them later ArrayList templateTabs = new ArrayList(); tabTemplate tab; // Create a new portal newPortalID = portals.AddPortal(portalAlias, portalName, portalPath); // Open the connection to the PortalTemplates Database SqlConnection myConnection = GetConnection(); SqlConnection my2ndConnection = GetConnection(); SqlConnection my3rdConnection = GetConnection(); myConnection.Open(); my2ndConnection.Open(); my3rdConnection.Open(); // get module definitions and save them in the new portal SqlDataReader myReader = GetTemplateModuleDefinitions(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { module.id = (int)myReader["ModuleDefID"]; module.GuidID = GetGeneralModuleDefinitionByName(myReader["FriendlyName"].ToString(), my2ndConnection); try { // save module definitions in the new portal modules.UpdateModuleDefinitions(module.GuidID, newPortalID, true); // Save the modules into a list for finding them later templateModules.Add(module); } catch { // tried to add a Module thas doesn´t exists in this implementation of the portal } } myReader.Close(); if (!PortalSettings.UseSingleUserBase) { int roleID; int userID; int adminRoleID = 0; // get roles and save them in the new portal myReader = GetPortalRoles(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { roleID = users.AddRole(newPortalID, myReader["RoleName"].ToString()); if (myReader["RoleName"].ToString() == "Admins") { adminRoleID = roleID; } } myReader.Close(); // Create the "admin" User for the new portal string AdminEmail = "*****@*****.**"; userID = users.AddUser("admin", AdminEmail, "admin", newPortalID); // Create a new row in a many to many table (userroles) // giving the "admins" role to the "admin" user users.AddUserRole(adminRoleID, userID); } // Get all the Tabs in the Template Portal, store IDs in a list for finding them later // and create the Tabs in the new Portal myReader = GetTabsByPortal(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { // Save the tabs into a list for finding them later tab.oldID = (int)myReader["TabID"]; tab.newID = tabs.AddTab(newPortalID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString())); templateTabs.Add(tab); } myReader.Close(); // now I have to get them again to set up the ParentID for each Tab myReader = GetTabsByPortal(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { // Find the news TabID and ParentTabID System.Collections.IEnumerator myEnumerator = templateTabs.GetEnumerator(); int newTabID = -1; int newParentTabID = -1; while (myEnumerator.MoveNext() && (newTabID == -1 || newParentTabID == -1)) { tab = (tabTemplate)myEnumerator.Current; if (tab.oldID == (int)myReader["TabID"]) { newTabID = tab.newID; } if (tab.oldID == Int32.Parse("0" + myReader["ParentTabID"])) { newParentTabID = tab.newID; } } if (newParentTabID == -1) { newParentTabID = 0; } // Update the Tab in the new portal tabs.UpdateTab(newPortalID, newTabID, newParentTabID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString()), myReader["AuthorizedRoles"].ToString(), myReader["MobileTabName"].ToString(), (bool)myReader["ShowMobile"]); // Finally use GetPortalSettings to access each Tab and its Modules in the Template Portal // and create them in the new Portal SqlDataReader result; try { result = GetTabModules(Int32.Parse(myReader["TabID"].ToString()), my2ndConnection); object myValue; while (result.Read()) { ModuleSettings m = new ModuleSettings(); m.ModuleID = (int)result["ModuleID"]; m.ModuleDefID = (int)result["ModuleDefID"]; m.TabID = newTabID; m.PaneName = (string)result["PaneName"]; m.ModuleTitle = (string)result["ModuleTitle"]; myValue = result["AuthorizedEditRoles"]; m.AuthorizedEditRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedViewRoles"]; m.AuthorizedViewRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedAddRoles"]; m.AuthorizedAddRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedDeleteRoles"]; m.AuthorizedDeleteRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedPropertiesRoles"]; m.AuthorizedPropertiesRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedMoveModuleRoles"]; m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedDeleteModuleRoles"]; m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["AuthorizedPublishingRoles"]; m.AuthorizedPublishingRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["SupportWorkflow"]; m.SupportWorkflow = !Convert.IsDBNull(myValue) ? (bool)myValue : false; myValue = result["AuthorizedApproveRoles"]; m.AuthorizedApproveRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty; myValue = result["WorkflowState"]; m.WorkflowStatus = !Convert.IsDBNull(myValue) ? (WorkflowState)(0 + (byte)myValue) : WorkflowState.Original; try { myValue = result["SupportCollapsable"]; } catch { myValue = DBNull.Value; } m.SupportCollapsable = DBNull.Value != myValue ? (bool)myValue : false; try { myValue = result["ShowEveryWhere"]; } catch { myValue = DBNull.Value; } m.ShowEveryWhere = DBNull.Value != myValue ? (bool)myValue : false; m.CacheTime = int.Parse(result["CacheTime"].ToString()); m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString()); myValue = result["ShowMobile"]; m.ShowMobile = !Convert.IsDBNull(myValue) ? (bool)myValue : false; // Find the new ModuleDefID assigned to the module in the new portal myEnumerator = templateModules.GetEnumerator(); int newModuleDefID = 0; while (myEnumerator.MoveNext() && newModuleDefID == 0) { module = (moduleTemplate)myEnumerator.Current; if (module.id == m.ModuleDefID) { newModuleDefID = modules.GetModuleDefinitionByGuid(newPortalID, module.GuidID); } } if (newModuleDefID > 0) { // add the module to the new tab int newModuleID = modules.AddModule(newTabID, m.ModuleOrder, m.PaneName, m.ModuleTitle, newModuleDefID, m.CacheTime, m.AuthorizedEditRoles, m.AuthorizedViewRoles, m.AuthorizedAddRoles, m.AuthorizedDeleteRoles, m.AuthorizedPropertiesRoles, m.AuthorizedMoveModuleRoles, m.AuthorizedDeleteModuleRoles, m.ShowMobile, m.AuthorizedPublishingRoles, m.SupportWorkflow, m.ShowEveryWhere, m.SupportCollapsable); // At the end, get all ModuleSettings and save them in the new module SqlDataReader dr = GetModuleSettings(m.ModuleID, my3rdConnection); while (dr.Read()) { ModuleSettings.UpdateModuleSetting(newModuleID, dr["SettingName"].ToString(), dr["SettingValue"].ToString()); } dr.Close(); } } result.Close(); } catch { // Error? ignore Tab ... } } myReader.Close(); // Set the CustomSettings of the New Portal based in the Template Portal myReader = GetPortalCustomSettings(templateID, myConnection); // Always call Read before accessing data. while (myReader.Read()) { PortalSettings.UpdatePortalSetting(newPortalID, myReader["SettingName"].ToString(), myReader["SettingValue"].ToString()); } myReader.Close(); // close the conections myConnection.Close(); myConnection.Dispose(); my2ndConnection.Close(); my2ndConnection.Dispose(); my3rdConnection.Close(); my3rdConnection.Dispose(); // Create paths portals.CreatePortalPath(portalPath); return(newPortalID); }
protected void btnUpdate_Click(object sender, EventArgs e) { string nemail = Session["email"].ToString(); Users nowuser = UsersDB.getUserbyEmail(nemail); string filename = "Default.png"; if (fldImage.HasFile) { filename = fldImage.FileName; fldImage.SaveAs(Server.MapPath("~/img/" + filename));//store the file in the images folder nowuser.profilepic = filename; Image1.ImageUrl = "~/img/" + nowuser.profilepic; } nowuser.name = tbxName.Text; nowuser.dob = Convert.ToDateTime(tbxDOB.Text); if (RadioMale.Checked) { nowuser.gender = "Male"; } else { nowuser.gender = "Female"; } if (RadioMSSingle.Checked) { nowuser.rstatus = "Single"; } else if (RadioMSWidowed.Checked) { nowuser.rstatus = "Widowed"; } else if (RadioMSDivorced.Checked) { nowuser.rstatus = "Divorced"; } else { nowuser.rstatus = "Married"; } nowuser.nationality = ddlNationality.SelectedValue; nowuser.bloodtype = ddlBloodType.SelectedValue; if (tbxHeight.Text == "") { nowuser.height = 0; } else { nowuser.height = Convert.ToInt32(tbxHeight.Text); } if (tbxWeight.Text == "") { nowuser.weight = 0; } else { nowuser.weight = Convert.ToInt32(tbxWeight.Text); } nowuser.address = tbxAddress.Text; nowuser.zipcode = Convert.ToInt32(tbxZipcode.Text); nowuser.phone = Convert.ToInt32(tbxPhone.Text); if (Panel1.Visible == true) { nowuser.emergencyname = tbxEName.Text; nowuser.emergencyphone = Convert.ToInt32(tbxEPhone.Text); nowuser.emergencyrelationship = ddlRelation.SelectedValue; } int num = UsersDB.updateUser(nowuser); if (num != 1) { lblOutput.Text = "Cannot Update User!"; } else { lblOutput.Text = "Update Successful!"; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["email"] == null) { Server.Transfer("CommonLogin.aspx"); } else { string nemail = Session["email"].ToString(); Users nowuser = UsersDB.getUserbyEmail(nemail); tbxName.Text = nowuser.name; if (nowuser.gender == "Male") { RadioMale.Checked = true; } else { RadioFemale.Checked = true; } tbxDOB.Text = String.Format("{0:yyyy-MM-dd}", nowuser.dob); ddlNationality.SelectedValue = nowuser.nationality; tbxNRIC.Text = nowuser.nric; if (nowuser.rstatus.Trim() == "Single") { RadioMSSingle.Checked = true; } else if (nowuser.rstatus.Trim() == "Married") { RadioMSMarried.Checked = true; } else if (nowuser.rstatus.Trim() == "Divorced") { RadioMSDivorced.Checked = true; } else { RadioMSWidowed.Checked = true; } tbxHeight.Text = nowuser.height.ToString(); tbxWeight.Text = nowuser.weight.ToString(); ddlBloodType.SelectedValue = nowuser.bloodtype; tbxEmail.Text = nowuser.email; tbxUsername.Text = nowuser.username; tbxAddress.Text = nowuser.address; tbxZipcode.Text = nowuser.zipcode.ToString(); tbxPhone.Text = nowuser.phone.ToString(); if (nowuser.emergencyname != "null") { Panel1.Visible = true; LinkButton1.Text = "I want to remove emergency contact person from my account."; tbxEName.Text = nowuser.emergencyname; tbxEPhone.Text = nowuser.emergencyphone.ToString(); ddlRelation.SelectedValue = nowuser.emergencyrelationship; } else { Panel1.Visible = false; LinkButton1.Text = "I want to add emergency contact person for me."; } List <Users> checkprolist = UsersDB.getallUserswithlink(); for (int n = 0; n < checkprolist.Count; n++) { if (nowuser.email == checkprolist[n].email) { i = 1; break; } else { i = 0; } } if (i == 1) { Image1.ImageUrl = nowuser.profilepic; } else { Image1.ImageUrl = "~/img/" + nowuser.profilepic; } } } }