public UserEntity Authenticate(string systemID, string password) { try { UserEntity user = new UserEntity(); int ret = 0; DataTable oTable = new DataTable(); using (Database db = new Database(GlobalObjects.CONNECTION_STRING)) { db.Open(); string sql = "AuthenticateUser"; db.ExecuteCommandReader(sql, new string[] { "@username", "@password" }, new DbType[] { DbType.String, DbType.String }, new object[] { systemID, password }, out ret, ref oTable, CommandTypeEnum.StoredProcedure); if (oTable.Rows.Count > 0) { DataRow oRow = oTable.Rows[0]; user = SetData(oRow); } } return user; } catch (Exception ex) { throw ex; } }
private void PopulateFields(int id) { newEntity = new UserEntity(); newEntity = newService.GetOne(id); lblUserName.Text = "(" + newEntity.UserName + ")"; lblName.Text = newEntity.FirstName + " " + newEntity.LastName; lblEmail.Text = newEntity.Email; lblMobile.Text = newEntity.PhoneNo; //txtNotes.Text = newEntity.Notes; if (newEntity.Picture != null) { imPicture.ImageUrl = string.Format("~/ShowImage.ashx?id={0}", id.ToString()); } else { imPicture.ImageUrl = "~/images/default_pic.png"; } if (GlobalObjects.IsAdmin) { btnEdit.Visible = true; } else { btnEdit.Visible = false; } }
private void PopulateFields(int id) { newEntity = new UserEntity(); newEntity = newService.GetOne(id); txtUserName.Text = newEntity.UserName; }
public Stream ShowEmpImage(int userId) { try { UserEntity newEntity = new UserEntity(); UserService newService = new UserService(); newEntity = newService.GetOne(userId); return new MemoryStream(newEntity.Picture); } catch { return null; } finally { } }
protected void Page_Init(object sender, EventArgs e) { if (Session["userid"] == null) { Response.Redirect("Login.aspx"); } else { int userId = (int)Session["userid"]; ent = serv.GetOne(userId); GlobalObjects.User = ent; if (ent.IsAdmin) { GlobalObjects.IsAdmin = true; } else { GlobalObjects.IsAdmin = false; } } }
public InvestorService() { appUsr = GlobalObjects.User; }
public DashboardService() { appUsr = GlobalObjects.User; }
public LoanService() { appUsr = GlobalObjects.User; }
private void PopulateFields(int id) { newEntity = new InvestorEntity(); newEntity = newService.GetOne(id); UserEntity usrEnt = new UserEntity(); UserService usrSrv = new UserService(); usrEnt = usrSrv.GetOne(newEntity.UserId); txtAmount.Text = newEntity.Amount.ToString(); txtNotes.Text = newEntity.Notes; ddlUser.SelectedValue = newEntity.UserId.ToString(); }
private UserEntity SetData(DataRow oRow) { try { UserEntity ent = new UserEntity(); ent.ID = Convert.ToInt32(oRow["id"]); ent.UserName = oRow["user_name"].ToString(); ent.Password = oRow["password"].ToString(); ent.FirstName = Utility.FormalFormat(oRow["first_name"].ToString()); ent.LastName = Utility.FormalFormat(oRow["last_name"].ToString()); ent.PhoneNo = oRow["phone_no"].ToString(); ent.Email = oRow["email"].ToString(); ent.Notes = oRow["notes"].ToString(); if (oRow["picture"] != DBNull.Value) { ent.Picture = (Byte[])oRow["picture"]; } ent.IsAdmin = Convert.ToBoolean(Convert.ToInt32(oRow["is_admin"])); ent.Status = Convert.ToInt32(oRow["status"]); return ent; } catch (Exception ex) { throw ex; } }
public UserEntity GetOne(int userId) { try { using (Database db = new Database(GlobalObjects.CONNECTION_STRING)) { db.Open(); string sql; int ret = 0; DataTable oTable = new DataTable(); sql = "GetUser"; db.ExecuteCommandReader(sql, new string[] { "@id" }, new DbType[] { DbType.Int32 }, new object[] { userId }, out ret, ref oTable, CommandTypeEnum.StoredProcedure); UserEntity user = new UserEntity(); if (oTable.Rows.Count > 0) { DataRow oRow = oTable.Rows[0]; user = SetData(oRow); } return user; } } catch (Exception ex) { throw ex; } }
public UserService() { appUsr = GlobalObjects.User; }
private void Update() { newEntity = new UserEntity(); newEntity.ID = id; newEntity.UserName = string.Empty; newEntity.Password = string.Empty; newEntity.FirstName = string.Empty; newEntity.LastName = string.Empty; newEntity.Email = txtEmail.Text.Trim(); newEntity.Notes = txtNotes.Text.Trim(); newEntity.PhoneNo = this.txtMobile.Text.Trim(); newEntity.IsAdmin = chkAdmin.Checked; if (this.fuImage.HasFile && fuImage.PostedFile != null) { //To create a PostedFile HttpPostedFile File = fuImage.PostedFile; //Create byte Array with file len newEntity.Picture = new Byte[File.ContentLength]; //force the control to load data in array File.InputStream.Read(newEntity.Picture, 0, File.ContentLength); } newService.Save(ActionType.Update, newEntity); SetMessage("User successfully updated"); //Response.Redirect("ManageUsers.aspx"); }
private void PopulateFields(int id) { newEntity = new UserEntity(); newEntity = newService.GetOne(id); txtUserName.Text = newEntity.UserName; chkAdmin.Checked = newEntity.IsAdmin; txtFirstName.Text = newEntity.FirstName; txtLastName.Text = newEntity.LastName; txtEmail.Text = newEntity.Email; txtMobile.Text = newEntity.PhoneNo; txtNotes.Text = newEntity.Notes; if (newEntity.Picture != null) { //imPicture.ImageUrl = string.Format("~/ShowImage.ashx?id={0}", id.ToString()); } else { //imPicture.ImageUrl = "~/img/default_pic.png"; } }
public PayableService() { appUsr = GlobalObjects.User; }
public WithdrawalService() { appUsr = GlobalObjects.User; }
public void Save(ActionType type, UserEntity user) { try { using (Database db = new Database(GlobalObjects.CONNECTION_STRING)) { db.Open(); int ret = 0; int hasPic = 0; int typ = (int)type; string sql = "SaveUser"; string[] asParams; DbType[] atParamTypes; object[] aoValues; Byte[] dummyPic; if (user.Picture != null) { hasPic = 1; dummyPic = user.Picture; } else { dummyPic = new byte[1000 * 1000 * 3]; } asParams = new string[] { "@actiontype", "@haspic", "@id", "@username", "@password", "@firstname", "@lastname", "@email", "@phoneno", "@notes", "@isadmin", "@picture", "@createdby", "@createddate", "@updatedby", "@updateddate"}; atParamTypes = new DbType[] { DbType.Int16, DbType.Int16, DbType.Int32, DbType.String, DbType.String, DbType.String, DbType.String, DbType.String, DbType.String, DbType.String, DbType.Int16, DbType.Binary, DbType.String, DbType.DateTime, DbType.String, DbType.DateTime }; aoValues = new object[] { typ, hasPic, user.ID, user.UserName, user.Password, user.FirstName, user.LastName, user.Email, user.PhoneNo, user.Notes, user.IsAdmin, dummyPic, appUsr.UserName, DateTime.Now, appUsr.UserName, DateTime.Now }; db.ExecuteCommandNonQuery(sql, asParams, atParamTypes, aoValues, out ret, CommandTypeEnum.StoredProcedure); } } catch (Exception ex) { throw ex; } }