public UserInfo(UserInfo userInfo) { this.id = userInfo.Id; this.code = userInfo.Code; this.name = userInfo.Name; this.password = userInfo.Password; this.role = userInfo.Role; this.content = userInfo.Content; this.eMail = userInfo.EMail; }
public static UserInfo GetUserById(int id) { UserInfo userInfo = new UserInfo(); StringBuilder sb = new StringBuilder(); sb.Append(" select * from user where Id = @Id "); MySqlParameter par = new MySqlParameter("@Id", MySqlDbType.Int16); par.Value = id; using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), par)) { while (reader.Read()) { userInfo = new UserInfo(reader); } } return userInfo; }
public static UserInfo GetUserByName(string name) { UserInfo userInfo = new UserInfo(); StringBuilder sb = new StringBuilder(); sb.Append(" select * from user where name =@name"); MySqlParameter par = new MySqlParameter("@name", MySqlDbType.String); par.Value = name; using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), par)) { while (reader.Read()) { //coll.Add(new UserInfo(reader)); userInfo = new UserInfo(reader); } } return userInfo; }
public static int InsertOrUpdatetoUser(UserInfo info) { int iSuccess = 0; MySqlTransaction mySqlTransaction = null; UserDAL.InsertOrUpdatetoUser(mySqlTransaction, info, out iSuccess); if (iSuccess > 0) { return 1; } else if (iSuccess == -1) { return -1; } else { return 0; } }
protected void btnlogin_Click(object sender, EventArgs e) { //coll = FBJHelper.Universal<UserCollection>.DeSerializeXMLToObject(str); //coll = JavaScriptConvert.DeserializeObject<UserCollection>(JavaScriptConvert.SerializeObject(str)); if (string.IsNullOrEmpty(this.txtUserName.Text.Trim())) { Alert.Show(this,"用户名不能为空!"); this.txtUserName.Focus(); return; } if (string.IsNullOrEmpty(this.txtPassword.Text.Trim())) { Alert.Show(this,"密码不能为空!"); this.txtPassword.Focus(); return; } userInfo = UserMethods.GetUserByCode(this.txtUserName.Text.Trim()); if (userInfo.Id > 0) { string str = Encryption.DESEncrypt(this.txtPassword.Text.Trim(),"19850627"); if (userInfo.Password.Equals(str)) { Session["UserCode"] = userInfo.Code; Server.Transfer("~/Views/BillingSystemMainPage.aspx"); } else { Alert.Show(this, "密码不正确"); this.txtPassword.Focus(); } } else if (userInfo.Id == 0) { Alert.Show(this,"此账号不存在"); } // //Response.Redirect("~/Views/BillingSystemMainPage.aspx"); }
public void AddRange(UserInfo[] value) { for (int i = 0; (i < value.Length); i++) { this.Add(value[i]); } }
/// <summary> /// Constructor using CcZlCzBillInfo array. /// </summary> /// <param name="value" /> public UserCollection(UserInfo[] value) { this.AddRange(value); }
public static void AddTableRow(DataTable table, UserInfo userInfo) { System.Data.DataRow dr = table.NewRow(); dr["Id"] = userInfo.id; dr["Code"] = userInfo.code; dr["Name"] = userInfo.name; dr["Password"] = userInfo.password; dr["EMail"] = userInfo.eMail; dr["Role"] = userInfo.role; dr["Content"] = userInfo.content; table.Rows.Add(dr); }
public void Insert(int index, UserInfo value) { List.Insert(index, value); innerListChanged = true; }
public void Remove(UserInfo value) { List.Remove(value); innerListChanged = true; }
public void CopyTo(UserInfo[] array, int index) { this.List.CopyTo(array, index); }
public int IndexOf(UserInfo value) { for (int i = 0, count = this.List.Count; i < count; i++) { if (value.Equals(this.List[i] as UserInfo)) return i; } return -1; }
private void Initialize(CardInfo info) { List<DropItem> listUser = new List<DropItem>(); UserCollection userColl = new UserCollection(); UserInfo loginInfo = new UserInfo(); if (Session["UserCode"] != null) { loginInfo = UserMethods.GetUserByCode(Session["UserCode"].ToString()); } userColl = UserMethods.GetUser(new List<QueryElement>()); if (userColl != null && userColl.Count > 0) { foreach (var userInfo in userColl) { listUser.Add(new DropItem { ValueField = userInfo.Id.ToString(), DisplayField = userInfo.Name }); } } this.dropAddBank.DataSource = StaticRescourse.GetBank(); Helper.SetDropDownList(this.dropAddBank); this.dropAddCardOwner.DataSource = listUser; Helper.SetDropDownList(this.dropAddCardOwner); this.dropAddCardUser.DataSource = listUser; Helper.SetDropDownList(this.dropAddCardUser); this.dropCardAddAccountType.DataSource = StaticRescourse.GetAccountType(); Helper.SetDropDownList(this.dropCardAddAccountType); if (info.Id > 0) { string str =info.OpenDate.ToString("yyyy-MM-dd"); int date = Convert.ToInt32(str.Substring(0,4)+str.Substring(5,2)+str.Substring(8,2)); this.dropAddBank.SelectedValue = info.BankId.ToString(); this.dropAddCardOwner.SelectedValue = info.OwnerId.ToString(); this.dropAddCardUser.SelectedValue = info.UserId.ToString(); this.dropCardAddAccountType.SelectedValue = info.AccountType.ToString(); this.txtAddCardNumber.Text = info.CardNumber; this.txtCardAddContent.Text = !string.IsNullOrEmpty(info.Content) ? info.Content : string.Empty; this.txtAddBankName.Text = !string.IsNullOrEmpty(info.BankName) ? info.BankName : string.Empty; this.txtAddCardOpenDate.Text = date > 20000101 ? info.OpenDate.ToString("yyyy-MM-dd") : string.Empty; this.txtAddCardNumber.Enabled = false; this.dropAddBank.Enabled = false; this.dropCardAddAccountType.Enabled = false; } else { this.txtAddCardNumber.Enabled = true; this.dropAddBank.Enabled = true; this.dropCardAddAccountType.Enabled = true; this.dropAddBank.SelectedIndex = 0; this.dropCardAddAccountType.SelectedIndex = 0; //this.dropAddCardOwner.SelectedValue = loginInfo.Id.ToString(); //this.dropAddCardUser.SelectedValue = loginInfo.Id.ToString(); this.txtAddCardOpenDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); } }
private void Initialize(UserInfo info) { this.dropRole.DataSource = StaticRescourse.GetRoleType(); Helper.SetDropDownList(this.dropRole); this.dropRole.DataBind(); if (info.Id > 0) { this.txtUserName.Text = !string.IsNullOrEmpty(info.Name) ? info.Name : string.Empty; this.txtIdCode.Text = info.Code; this.txtPassword.Attributes.Add("value",info.Password); this.dropRole.SelectedValue = info.Role.ToString(); this.txtEmail.Text = !string.IsNullOrEmpty(info.EMail) ? info.EMail : string.Empty; this.txtContent.Text = !string.IsNullOrEmpty(info.content) ? info.content : string.Empty; } else { this.dropRole.SelectedValue = "1"; } }
public int Add(UserInfo value) { return this.List.Add(value); }
public static int InsertOrUpdatetoUser(UserInfo info) { return UserProxy.InsertOrUpdatetoUser(info); }
protected void btnUserEditSave_Click(object sender, EventArgs e) { #region 验证 this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserAdddiv();", true); if (string.IsNullOrEmpty(this.txtIdCode.Text.Trim())) { Alert.Show(this, "请输入IdCode!"); this.txtIdCode.Focus(); return; } if (this.txtIdCode.Text.Trim().Length > 10 || this.txtIdCode.Text.Trim().Length < 5) { Alert.Show(this, "请输入长度在5到10之间的IdCode!"); this.txtIdCode.Focus(); return; } //if (string.IsNullOrEmpty(Request.QueryString["Code"])) if (string.IsNullOrEmpty(this.HiddenField1.Value)) { if (string.IsNullOrEmpty(this.txtPassword.Text.Trim())) { Alert.Show(this, "请输入密码!"); this.txtPassword.Focus(); return; } if (this.txtPassword.Text.Trim().Length < 6 || this.txtPassword.Text.Trim().Length > 18) { Alert.Show(this, "请输入长度在6到18之间的密码!"); this.txtPassword.Focus(); return; } } #endregion UserInfo userInfo = new UserInfo(); userInfo.Name = this.txtUserName.Text.Trim(); userInfo.Code = this.txtIdCode.Text.Trim(); userInfo.Password = FBJHelper.Encryption.DESEncrypt(this.txtPassword.Text.Trim(),"19850627"); userInfo.Role = Convert.ToInt32(this.dropRole.SelectedValue); userInfo.content = this.txtContent.Text.Trim(); userInfo.EMail = this.txtEmail.Text.Trim(); int isuccess = UserMethods.InsertOrUpdatetoUser(userInfo); this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserAdddiv();", true); if (isuccess > 0) { Alert.Show(this, "新增用户成功!"); ClearEditFrom(); } else if (isuccess == -1) { Alert.Show(this, "修改用户成功!"); ClearEditFrom(); } else { Alert.Show(this, "操作失败!"); } BindDataGrid(queryList); //if (i > 0) //{ //this.ClientScript.RegisterStartupScript(this.GetType(), "", "closeWin();", true); //Response.Write("<script type='text/javascript'>window.opener = null; window.close();</script>"); //} }
public bool Contains(UserInfo value) { if (IndexOf(value) > -1) return true; return false; }
//public static UserCollection GetUser(string[] strFields, string[] strValues) //{ //UserCollection coll = new UserCollection(); //StringBuilder sb = new StringBuilder(); //sb.Append("select * from user "); //if (strFields != null && strFields.Length > 0) //{ // MySqlParameter[] pars = new MySqlParameter[strFields.Length]; // for (int i = 0; i < strFields.Length; i++) // { // if (i == 0) // { // sb.Append("where"); // } // else // { // sb.Append("AND "); // } // sb.AppendFormat(" {0}=@{1}", strFields[i], strFields[i]); // pars[i] = GetParType("@" + strFields[i]); // int backvalue = SetValue(strFields[i]); // if (backvalue == 1) // { // pars[i].Value = strValues[i]; // } // else if (backvalue == 2) // { // pars[i].Value = Convert.ToInt32(strValues[i]); // } // } // using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), pars)) // { // while (reader.Read()) // { // coll.Add(new UserInfo(reader)); // } // } //} //else //{ // using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString())) // { // while (reader.Read()) // { // coll.Add(new UserInfo(reader)); // } // } //} //return coll; //} #endregion /*INSERT INTO table_name VALUES (value1,value2,value3,...); INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...); */ /// <summary> /// 新增或修改 /// </summary> /// <param name="mySqlTransaction"></param> /// <param name="info"></param> /// <param name="iSuccess"></param> public static void InsertOrUpdatetoUser(MySqlTransaction mySqlTransaction, UserInfo info, out int iSuccess) { StringBuilder sb = new StringBuilder(); UserInfo userInfo = GetUserByCode(info.Code); if (userInfo.Id > 0) { sb.Append(" update user set Code = @Code,Name = @Name,Password=@Password,Role = @Role,Content = @Content where id = @id "); info.Id = userInfo.Id; } else { sb.Append(" insert into user (Code,Name,Password,EMail,Role,Content) Values (@Code,@Name,@Password,@EMail,@Role,@Content ) "); } MySqlParameter[] pars = new MySqlParameter[] { new MySqlParameter("@id",MySqlDbType.Int32), new MySqlParameter("@Code",MySqlDbType.String), new MySqlParameter("@Name",MySqlDbType.String), new MySqlParameter("@Password",MySqlDbType.String), new MySqlParameter("@EMail",MySqlDbType.String), new MySqlParameter("@Role",MySqlDbType.Int32), new MySqlParameter("@Content",MySqlDbType.String) }; pars[0].Value = info.Id; pars[1].Value = info.Code; pars[2].Value = info.Name; pars[3].Value = info.Password; pars[4].Value = info.EMail; pars[5].Value = info.Role; pars[6].Value = info.content; iSuccess = MySqlDBHelper.ExecuteCommand(mySqlTransaction, sb.ToString(), pars); if (info.Id > 0) { iSuccess = -1; } }