protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string strMessage = string.Empty; string strCheck = string.Empty; string strScript = string.Empty; string strUpdatedBy = Session["username"].ToString(); Label lblperson_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblperson_code"); HiddenField hdduserID = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("hdduserID"); cUser oUser = new cUser(); try { if (!oUser.SP_USER_DEL(hdduserID.Value.ToString(), ref strMessage)) { lblError.Text = strMessage; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { oUser.Dispose(); } BindGridView(0); }
private void getArtistInfo() { cUser tatt1 = new cUser(); cUser tatt2 = new cUser(); cUser tatt3 = new cUser(); cDAL4 dal = new cDAL4(); tatt1 = dal.getArtistInfo(1); tatt2 = dal.getArtistInfo(2); tatt3 = dal.getArtistInfo(3); tbArtist1.Text = tatt1.FirstName.ToString(); tbArtist11.Text = tatt1.LastName.ToString(); tbArtist111.Text = tatt1.PhoneNumber.ToString(); tbArtist1111.Text = tatt1.Email.ToString(); tbArtist2.Text = tatt3.FirstName.ToString(); tbArtist22.Text = tatt3.LastName.ToString(); tbArtist222.Text = tatt3.PhoneNumber.ToString(); tbArtist2222.Text = tatt3.Email.ToString(); tbArtist3.Text = tatt2.FirstName.ToString(); tbArtist33.Text = tatt2.LastName.ToString(); tbArtist333.Text = tatt2.PhoneNumber.ToString(); tbArtist3333.Text = tatt2.Email.ToString(); }
private void EmailsChangesUpdate(cUser Demography) { List <cEMail> emails = Session["dem_Emails"] as List <cEMail>; int userId = (int)Session["UserID"]; //For each element of the original list perform one of the following: //If update, update information //If delete, mark record for delete //If new, mark record for adding cEMail a1 = null; if (Demography.UserEmails != null) { foreach (cEMail a in Demography.UserEmails) //state in database { a1 = emails.FirstOrDefault(x => x.EMailID == a.EMailID); //If record not found in memory that means it was deleted if (a1 == null) { a.SaveUpdate(userId, true); } else { a1.SaveUpdate(userId); } } } a1 = emails.FirstOrDefault(x => x.EMailID <= 0); if (a1 != null && a1.IsValid()) // If new and valid, let push it to the database { a1.SaveUpdate(userId); } }
private void getPersonalInfo(Int16 UserId) { cUser myUser = new cUser(); cDAL dal = new cDAL(); myUser = dal.PersonalInformation(UserId); tbInfo2.Text = myUser.FirstName.ToString(); tbInfo3.Text = myUser.LastName.ToString(); tbInfo4.Text = myUser.PhoneNumber.ToString(); tbInfo5.Text = myUser.County.ToString(); tbInfo6.Text = myUser.Street.ToString(); tbInfo7.Text = myUser.ZIP.ToString(); btnLogIn.Visible = false; btnRegistry.Visible = false; btnLogOut.Visible = true; lbLogInText.Visible = false; btnLogIn2.Visible = false; UserImg1.Visible = true; tbInfo2.Visible = true; tbInfo3.Visible = true; tbInfo4.Visible = true; tbInfo5.Visible = true; tbInfo6.Visible = true; tbInfo7.Visible = true; btnChangeInfo.Visible = true; }
public DataTable getUserReservation2(Int16 UserId) { DataTable dt = new DataTable(); // New object cUser myUser = new cUser(); // Create a connection SqlConnection conn = new SqlConnection(connStr); // Name of the Procedure I want to call SqlCommand cmd = new SqlCommand("uspUserReservation", conn); // Type of commad I want to execute cmd.CommandType = CommandType.StoredProcedure; try { // Open the connection to the database conn.Open(); // Insert the Parameter to the procedure cmd.Parameters.AddWithValue("@UserID", UserId); // Execute my procedure and load the result to dr dt.Load(cmd.ExecuteReader()); return(dt); } catch { // If error throw; } finally { // Close and dispose all connections to the databse cmd.Dispose(); conn.Close(); conn.Dispose(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,PhoneNo")] cUser cUser) { if (id != cUser.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!cUserExists(cUser.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cUser)); }
public cAcceptanceStatus Get(cUser user, int versionId) { return(_Context.AcceptanceStatuses.Include(x => x.Version) .Where(x => EF.Property <int>(x, "CreatedBy") == user.Id && x.Version.Id == versionId) .OrderBy(x => EF.Property <DateTime>(x, "LastUpdatedOn")) .FirstOrDefault()); }
public IActionResult Get() { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } cUser user = cHelper.User(HttpContext, _UnitOfWork); var userRole = _UnitOfWork.UserRoleRepository.Get(user); var result = new { FirstName = userRole.User.FirstName, MiddleName = userRole.User.MiddleName, LastName = userRole.User.LastName, Email = userRole.User.Email, Phone = userRole.User.Phone, RoleName = userRole.Role.RoleName, Username = userRole.User.UserName, Address = userRole.User.Address }; return(Ok(result)); } catch (Exception exception) { Log.WriteLine(exception); return(StatusCode(500)); } }
protected void btn_save_Click(object sender, EventArgs e) { string UpdateCommand = "UPDATE [smUser] SET [pwd] = @pwd WHERE [userid] = @userid"; SqlParameter[] par = new SqlParameter[2]; par[0] = new SqlParameter("@pwd", SqlDbType.NVarChar, 40); par[0].Value = Entry.EncryptByMd5(txt_newpass1.Text.ToString().Trim()); par[1] = new SqlParameter("@userid", SqlDbType.Int); par[1].Value = Ulable1.TextValue; cUser cus = new cUser(); int val = -10; try { if (this.Page.IsValid == false) { return; } val = cus.ModiUser(UpdateCommand, par); if (val > 0) { Script.AjaxAlert(btn_save, "恭喜您,密码修改成功,请牢记您的密码!"); } } catch { Script.AjaxAlert(btn_save, "对不起,密码修改失败,请联系系统管理员!"); } }
protected override void Execution(CallbackQuery c) { if (ThisChat.FullPidor == "" || ThisChat.FullPidor == null) { new InfoService($"В чате '{ThisChat.Name}' еще нет 'пидора' "); return; } cUser c_current_user = ThisChat.users.Find(t => t.FullName == ThisChat.FullPidor); c_current_user.CountPidor = c_current_user.CountPidor - 1; var newPidor = setPidor(ThisChat, thisUser); new Task(() => FindingPidor(ThisChat, newPidor)).Start(); string outStr = $"<b>Complete.</b> Чат=> <b>* ) '{ThisChat.Name}'</b> [{ThisChat.Id_tg}] - " + $"\n'Підор' =<b>{ThisChat.FullPidor}</b>; [Последний раз(дата):{ThisChat.DatePidor}]" + $"\n'Батя' =<b>{ThisChat.FullDad}</b>; [Последний раз(дата):{ThisChat.DateDad}]"; new Menu ( new User().getButton_Name("Ок", Argument[0], Argument[1]), c.Message.MessageId, outStr ); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } if (Session["UserID"] != null) { int.TryParse(Session["UserID"].ToString(), out _UserID); } if (Session["UserName"] != null) { _UserName = Session["UserName"].ToString(); } if ((Session["CampaignsToEdit"] == null) || (Session["MyCharacters"] == null)) { Classes.cUser UserInfo = new cUser(_UserName, "PasswordNotNeeded"); Session["CharacterSelectID"] = UserInfo.LastLoggedInCharacter; if (UserInfo.LastLoggedInMyCharOrCamp == "C") { WhichSelected = Selected.CampaignCharacters; Session["CharacterSelectCampaign"] = UserInfo.LastLoggedInCampaign; Session["CharacterCampaignCharID"] = UserInfo.LastLoggedInCharacter; Session["CharacterSelectGroup"] = "Campaigns"; } else { WhichSelected = Selected.MyCharacters; } } }
public IActionResult SignUp([FromBody] SignUpAuthActionModel actionModel) { try { cUser user = new cUser() { Email = actionModel.Email, UserName = actionModel.UserName, HashedPassword = actionModel.Password, DomainId = Convert.ToInt32(actionModel.Domain) }; cUserRole userRole = new cUserRole() { User = user, IsActive = true, Role = _UnitOfWork.RoleRepository.Get(actionModel.Role) }; using (_UnitOfWork) { var domain = _UnitOfWork.DomainRepository.Get(Convert.ToInt32(actionModel.Domain)); userRole.User.DomainId = domain == null ? 0: domain.Id; _UnitOfWork.UserRoleRepository.Set(userRole); _UnitOfWork.Complete(); } return(StatusCode(200, user)); } catch (Exception exception) { Log.WriteLine(exception); return(StatusCode(500)); } }
void CleanAll() { this.Argument_ = null; this.ThisChat_ = null; this.ThisUser_ = null; this.chatID_ = 0; Current_Command_ = null; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { userid = testUsers[this.comboBox1.SelectedIndex + 1].id; // 得到当前用户ID cUser currentUser = sourceUsers[userid]; this.textBox1.Text = currentUser.RatingNums.ToString(); this.textBox2.Text = (currentUser.Ratings.Length - currentUser.RatingNums - 1).ToString(); bool[] b_isLoved = currentUser.discretizeRating(); this.dataGridView1.Rows.Clear(); this.dataGridView2.Rows.Clear(); string sGenres = ""; // 电影类型 int count_love = 0, count_dislove = 0; // 填充用户观影数据 for (int itemid = 1; itemid < currentUser.Ratings.Length; itemid++) { double rating = currentUser.Ratings[itemid]; if (rating != 0) { sGenres = ""; for (int count_gen = 0; count_gen < objs_movieInfo[itemid].genres.Length; count_gen++) { // 形成影片类型字符串 if (objs_movieInfo[itemid].genres[count_gen] != "") { sGenres += objs_movieInfo[itemid].genres[count_gen] + " /"; } } if (sGenres != "") { sGenres = sGenres.Substring(0, sGenres.Length - 1); } // 喜欢这部电影 if (b_isLoved[itemid] == true) { // 添加电影信息记录 this.dataGridView1.Rows.Add(itemid, rating, objs_movieInfo[itemid].name, objs_movieInfo[itemid].ReleaseDate, sGenres); count_love++; } // 不喜欢这部电影 else { this.dataGridView2.Rows.Add(itemid, rating, objs_movieInfo[itemid].name, objs_movieInfo[itemid].ReleaseDate, sGenres); count_dislove++; } } } // 喜欢与不喜欢的数量 this.label_lovenum.Text = count_love.ToString(); this.label_dislovenum.Text = count_dislove.ToString(); }
protected bool SetUserProfile(string strUserName, ref string _strError) { bool booResult = false; cPerson objPerson = new cPerson(); cUser objUser = new cUser(); DataTable dt = new DataTable(); DataSet ds = new DataSet(); string strCriteria; string strMessage = string.Empty; strCriteria = " And person_id='" + strUserName + "' "; objUser.SP_PERSON_USER_SEL(strCriteria, ref ds, ref strMessage); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { base.PersonId = strUserName; this.UserGroupList = Helper.CStr(dt.Rows[0]["user_group_list"]); string[] ArrUserGroup = this.UserGroupList.Split(','); if (ArrUserGroup.Length > 1) { cCommon oCommon = new cCommon(); strMessage = string.Empty; strCriteria = string.Empty; ds = new DataSet(); dt = new DataTable(); string struser_group_list = string.Empty; foreach (string str in ArrUserGroup) { struser_group_list += "'" + str + "',"; } if (struser_group_list.Length > 0) { struser_group_list = struser_group_list.Substring(0, struser_group_list.Length - 1); } strCriteria = " Select * from user_group where user_group_code in (" + struser_group_list + ")"; if (oCommon.SEL_SQL(strCriteria, ref ds, ref strMessage)) { dt = ds.Tables[0]; rptUserGroupSelect.DataSource = dt; rptUserGroupSelect.DataBind(); WarningModal.Show(); } } else { this.UserGroupCode = ArrUserGroup[0].Trim(); //this.UserGroupCode = "001"; GotoUserMode(this.UserGroupCode); } booResult = true; } else { _strError = "ไม่พบผู้ใช้งานนี้"; } return(booResult); }
private void button1_Click(object sender, EventArgs e) { // 记录当前时间 int count_predit = 0; DateTime dt_1 = DateTime.Now; Rec_Items_num = int.Parse(this.textBox9.Text); userRating = new Dictionary <int, float>(); // 得到用户 cUser testUser = testUsers[comboBox2.SelectedIndex + 1]; userid = testUser.id; userRating = new Dictionary <int, float>(); for (int j = 1; j < trainUsers[userid].Ratings.Length; j++) { if (trainUsers[userid].Ratings[j] != 0) { userRating.Add(j, (float)trainUsers[userid].Ratings[j]); } } // count_predit = trainUsers[userID].Ratings.Length - trainUsers[userID].RatingNums; // 得到该用户的预测评分 IDictionary <int, float> Predictions = obj_SlopeOne.Predict(userRating); obj_AssStrategy = obj_SlopeOne.getAssStrategy(userid, Predictions, Rec_Items_num, testUser); DateTime dt_2 = DateTime.Now; TimeSpan ts = dt_2.Subtract(dt_1); this.textBox4.Text = obj_AssStrategy.MAE.ToString(); // MAE this.textBox5.Text = ts.TotalMilliseconds + "ms"; // 时间 this.textBox6.Text = obj_AssStrategy.Precison.ToString(); // 查准率 this.textBox8.Text = obj_AssStrategy.Recall.ToString(); // 查全率 float F = obj_AssStrategy.calculateF_Measure(); // F1指标 this.textBox7.Text = F.ToString(); this.textBox2.Text = this.Rec_Items_num.ToString(); // Top-N 推荐数 this.textBox3.Text = "MAE:" + obj_AssStrategy.MAE + " 查准率:" + obj_AssStrategy.Precison + " 查全率:" + obj_AssStrategy.Recall + " F值:" + F + " 总耗时:" + ts.TotalMilliseconds + "ms"; // this.dataGridView1.Rows.Add(count_dgv++, trainUsers[userIndex].id, this.Rec_Items_num, trainUsers[userIndex].RatingNums, obj_AssStrategy.MAE, obj_AssStrategy.Precison, // obj_AssStrategy.Recall, F, ts.TotalMilliseconds + " ms"); Application.DoEvents(); stat_Info[trainUsers[userid].RatingNums / 50] += obj_AssStrategy.MAE; count_Num[trainUsers[userid].RatingNums / 50]++; // 累加相关数据 total_MAE += obj_AssStrategy.MAE; total_Precison += obj_AssStrategy.Precison; total_Recall += obj_AssStrategy.Recall; total_F_Measure += F; total_Time += ts.TotalMilliseconds; }
private void setData() { cUser oUser = new cUser(); DataSet ds = new DataSet(); string strMessage = string.Empty, strCriteria = string.Empty; try { strCriteria = " and UserID = '" + ViewState["userID"].ToString() + "' "; if (!oUser.SP_USER_SEL(strCriteria, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count > 0) { #region get Data hddUserID.Value = ds.Tables[0].Rows[0]["UserID"].ToString(); txtperson_code.Text = ds.Tables[0].Rows[0]["person_code"].ToString(); txtperson_name.Text = ds.Tables[0].Rows[0]["person_thai_name"].ToString() + " " + ds.Tables[0].Rows[0]["person_thai_surname"].ToString(); txtperson_group_name.Text = ds.Tables[0].Rows[0]["person_group_name"].ToString(); txtdirector_name.Text = ds.Tables[0].Rows[0]["director_name"].ToString(); txtunit_name.Text = ds.Tables[0].Rows[0]["unit_name"].ToString(); txtemail.Text = ds.Tables[0].Rows[0]["email"].ToString(); txtloginname.Text = ds.Tables[0].Rows[0]["loginname"].ToString(); hddusername.Value = ds.Tables[0].Rows[0]["loginname"].ToString(); txtpassword.Text = Cryptorengine.Decrypt(ds.Tables[0].Rows[0]["password"].ToString(), true); string strBudget_type = ds.Tables[0].Rows[0]["budget_type"].ToString(); InitcboBudgetType(); if (cboBudget_type.Items.FindByValue(strBudget_type) != null) { cboBudget_type.SelectedIndex = -1; cboBudget_type.Items.FindByValue(strBudget_type).Selected = true; } if (ds.Tables[0].Rows[0]["status"].ToString() == "Y") { chkStatus.Checked = true; } else { chkStatus.Checked = false; } InitcboUser_group(); cbouser_group.SelectedValue = ds.Tables[0].Rows[0]["user_group_code"].ToString(); txtUpdatedBy.Text = ds.Tables[0].Rows[0]["UpdatedBy"].ToString();; txtUpdatedDate.Text = cCommon.CheckDate(ds.Tables[0].Rows[0]["UpdatedDate"].ToString()); #endregion } } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } }
/*====================================================*/ public virtual void EventController_Notify_DataModified(cDataObjectFactory aDataObjectFactory, Hashtable aDataObjHash) { if (cReflection.TypeBasedFrom(WebSession.CurrentPage.GetType(), "Core", "Core.Web.Modules.cModulePage")) { cModulePage aPage = (cModulePage)WebSession.CurrentPage; cUser aUser = aPage.ModuleUser; if (aUser != null) aUser.Notify_DataModified(WebSession.DataObjectFactory, null); } }
public async Task <IActionResult> Create([Bind("Id,Name,Email,PhoneNo")] cUser cUser) { if (ModelState.IsValid) { _context.Add(cUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cUser)); }
private void getPersonalInfo(Int16 UserId) { cUser myUser = new cUser(); cDAL dal = new cDAL(); myUser = dal.PersonalInformation(UserId); btnLogIn.Visible = false; btnRegistry.Visible = false; btnLogOut.Visible = true; }
public cUser getUserReservation(Int16 UserId) { // New object cUser myUser = new cUser(); // Create a connection SqlConnection conn = new SqlConnection(connStr); // Name of the Procedure I want to call SqlCommand cmd = new SqlCommand("uspUserReservation", conn); // Type of commad I want to execute cmd.CommandType = CommandType.StoredProcedure; try { // Open the connection to the database conn.Open(); // Insert the Parameter to the procedure cmd.Parameters.AddWithValue("@UserID", UserId); // Execute my procedure and load the result to dr SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { myUser.Meeting = dr["Meeting"].ToString(); myUser.Date = dr["Date"].ToString(); myUser.Day = dr["Day"].ToString(); myUser.Month = dr["Month"].ToString(); myUser.Starting = dr["Starting"].ToString(); myUser.Ending = dr["Ending"].ToString(); myUser.TattoArtist = dr["TattoArtist"].ToString(); myUser.ReservationID = Convert.ToInt16(dr["ReservationID"].ToString()); } } return(myUser); } catch { // If error throw; } finally { // Close and dispose all connections to the databse cmd.Dispose(); conn.Close(); conn.Dispose(); } }
protected void DataBindGV() { cUser cuser = new cUser(); try { DataTable dt = cuser.GetAllUserDatatable(); gv.DataSource = dt; gv.DataBind(); } catch { } }
private void getContactInformation() { cUser myUser = new cUser(); cDAL5 dal = new cDAL5(); myUser = dal.getContactInfo(); tbContact1.Text = myUser.PhoneNumber.ToString(); tbContact2.Text = myUser.Street.ToString(); tbContact3.Text = myUser.ZIP.ToString(); tbContact4.Text = myUser.County.ToString(); tbContact5.Text = myUser.Email.ToString(); }
public void AddUserToSnapshot(User newUser) { cUser newDataUser = new cUser { Id = 0, //not necessary - generated in data layer Login = newUser.Login, FirstName = newUser.FirstName, LastName = newUser.LastName, PasswordPublic = SecurityUtils.EncryptPlainTextToCipherText(newUser.PasswordPrivate) }; DataUsers.AddUser(newDataUser); }
public cUser makeRegistry(String UserName, String Email, String FirstName, String LastName, String SSN, String PhoneNumber, String Street, String ZIP, String County, String Password) { // New object cUser myUser = new cUser(); // Create a connection SqlConnection conn = new SqlConnection(connStr); // Name of the Procedure I want to call SqlCommand cmd = new SqlCommand("uspRegistry", conn); // Type of commad I want to execute cmd.CommandType = CommandType.StoredProcedure; try { // Open the connection to the database conn.Open(); // Insert the Parameter to the procedure cmd.Parameters.AddWithValue("@UserName", myUser.UserName); cmd.Parameters.AddWithValue("@Email", myUser.Email); cmd.Parameters.AddWithValue("@FirstName", myUser.FirstName); cmd.Parameters.AddWithValue("@LastName", myUser.LastName); cmd.Parameters.AddWithValue("@SSN", myUser.SSN); cmd.Parameters.AddWithValue("@PhoneNumber", myUser.PhoneNumber); cmd.Parameters.AddWithValue("@Street", myUser.Street); cmd.Parameters.AddWithValue("@ZIP", myUser.ZIP); cmd.Parameters.AddWithValue("@County", myUser.County); cmd.Parameters.AddWithValue("@Password", myUser.Password); // Execute my procedure and load the result to dr SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { myUser.UserId = Convert.ToInt16(dr["UserID"].ToString()); } } return(myUser); } catch { // If error throw; } finally { // Close and dispose all connections to the databse cmd.Dispose(); conn.Close(); conn.Dispose(); } }
public cUser changeInformation(Int16 iUserId, String sFirstName, String sLastName, String sPhoneNumber, String sCounty, String sStreet, String sZIP) { // New object cUser myUser = new cUser(); // Create a connection SqlConnection conn = new SqlConnection(connStr); // Name of the Procedure I want to call SqlCommand cmd = new SqlCommand("uspChangePersonalInformation", conn); // Type of commad I want to execute cmd.CommandType = CommandType.StoredProcedure; try { // Open the connection to the database conn.Open(); // Insert the Parameter to the procedure cmd.Parameters.AddWithValue("@UserID", iUserId); cmd.Parameters.AddWithValue("@FirstName", sFirstName); cmd.Parameters.AddWithValue("@LastName", sLastName); cmd.Parameters.AddWithValue("@PhoneNumber", sPhoneNumber); cmd.Parameters.AddWithValue("@County", sCounty); cmd.Parameters.AddWithValue("@Street", sStreet); cmd.Parameters.AddWithValue("@ZIP", sZIP); // Execute my procedure and load the result to dr SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { myUser.UserId = Convert.ToInt16(dr["Resultat"].ToString()); } } return(myUser); } catch { // If error throw; } finally { // Close and dispose all connections to the databse cmd.Dispose(); conn.Close(); conn.Dispose(); } }
protected void btnLogin_Click(object sender, EventArgs e) { cUser user = new cUser(); // check the users login info, if it is valid, return a cUser object representing that user - otherwise null is returned user = cUser.Verify(txtEmail.Text, "a"); // if user isn't null, we have a validated user and can proceed to the main page... if (user != null) { Session.Add("objUser", user); Session.Add("Email", user.Email); Response.Redirect("index.aspx"); } Response.Redirect("login.aspx?valid=false"); }
public cUser PersonalInformation(Int16 UserId) { // New object cUser myUser = new cUser(); // Create a connection SqlConnection conn = new SqlConnection(connStr); // Name of the Procedure I want to call SqlCommand cmd = new SqlCommand("uspPersonalInformation", conn); // Type of commad I want to execute cmd.CommandType = CommandType.StoredProcedure; try { // Open the connection to the database conn.Open(); // Insert the Parameter to the procedure cmd.Parameters.AddWithValue("@UserID", UserId); // Execute my procedure and load the result to dr SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { myUser.UserName = dr["UserName"].ToString(); myUser.FirstName = dr["FirstName"].ToString(); myUser.LastName = dr["LastName"].ToString(); myUser.PhoneNumber = dr["PhoneNumber"].ToString(); myUser.County = dr["County"].ToString(); myUser.Street = dr["Street"].ToString(); myUser.ZIP = Convert.ToInt32(dr["ZIP"].ToString()); } } return(myUser); } catch { // If error throw; } finally { // Close and dispose all connections to the databse cmd.Dispose(); conn.Close(); conn.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { cUser user = _business.GetUser(); if (user != null) { name.Text = user.name; surname.Text = user.surname; cpf.Text = user.cpf; email.Text = user.email; tel.Text = user.tel; cel.Text = user.cel; } } }
public static string SetUser(cUser cUser) { long enterpriseId = Convert.ToInt64(cWebCrypto.Decrypt(HttpContext.Current.Request.QueryString["ac"])); long userId = GetLogged().userId; _context = cDataContextFactory.GetDataContext(); if (_context.ACAD_USUARIOS.Where(x => x.CD_ACADEMIA == enterpriseId && x.TX_EMAIL == cUser.email && (userId == 0 || x.CD_USUARIO != userId)).Count() > 0) { return("-1"); } ACAD_USUARIOS user = new ACAD_USUARIOS(); if (userId > 0) { user = _context.ACAD_USUARIOS.Where(x => x.CD_USUARIO == userId).FirstOrDefault(); } user.CD_ACADEMIA = enterpriseId; user.NM_USUARIO = cUser.name; user.NM_SOBRENOME = cUser.surname; user.TX_EMAIL = cUser.email; user.TX_TELEFONE = cUser.tel; user.TX_CELULAR = cUser.cel; user.TX_CPF = cUser.cpf; if (!string.IsNullOrEmpty(cUser.password)) { user.TX_SENHA = cUser.password; } user.TX_IP = cUser.ip; user.FL_ATIVO = true; if (userId == 0) { user.DT_DATA = DateTime.Now; _context.Entry(user).State = System.Data.Entity.EntityState.Added; } else { _context.Entry(user).State = System.Data.Entity.EntityState.Modified; } _context.SaveChanges(); return(cWebCrypto.Encrypt(user.CD_USUARIO.ToString())); }
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { cUser myUser = new cUser(); cUser myResultUser = new cUser(); DAL myDAL = new DAL(); myUser.Password = Login1.Password.ToString(); myUser.UserName = Login1.UserName.ToString(); myResultUser = myDAL.Login(myUser); if (myResultUser.UserId > 0) { Login1.UserName = myResultUser.UserId.ToString(); Session.Add("UserId", myResultUser.UserId.ToString()); Response.Redirect("MyPage.aspx"); } }