public static void UpdateData(DataObject.SysUser obj) { SqlConnection conn = Common.Connection.SqlConnect(); String Update = "UPDATE SYS_USER SET Password = @Password, Email = @Email, DeptId = @DeptId, OrgId = @OrgId Where ID = @ID"; SqlCommand cmd = new SqlCommand(Update); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.Parameters.AddWithValue("@Password", obj.Password); cmd.Parameters.AddWithValue("@Email", obj.Email); cmd.Parameters.AddWithValue("@DeptId", obj.DeptId); cmd.Parameters.AddWithValue("@OrgId", obj.OrgId); cmd.Parameters.AddWithValue("@ID", obj.ID); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); }
public static void InsertData(DataObject.SysUser obj) { String Insert = "INSERT INTO SYS_USER (UserName,Password,Email,DeptId,OrgId,Create_User,Create_Date) VALUES "; Insert += "(@UserName,@Password,@Email,@DeptId,@OrgId,@Create_User,@Create_Date)"; SqlConnection conn = Common.Connection.SqlConnect(); SqlCommand cmd = new SqlCommand(Insert); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.Parameters.AddWithValue("@UserName", obj.UserName); cmd.Parameters.AddWithValue("@Password", obj.Password); cmd.Parameters.AddWithValue("@Email", obj.Email); cmd.Parameters.AddWithValue("@DeptId", obj.DeptId); cmd.Parameters.AddWithValue("@OrgId", obj.OrgId); cmd.Parameters.AddWithValue("@Create_User", obj.Create_User); cmd.Parameters.AddWithValue("@Create_Date", obj.Create_Date); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); }
public static List <DataObject.SysUser> GetDataByUserName(string userName) { List <DataObject.SysUser> lstSysUser = new List <DataObject.SysUser>(); String Select = ""; SqlCommand cmd = null; SqlConnection conn = Common.Connection.SqlConnect(); if (userName != "") { Select = "Select * from SYS_USER Where UserName = @UserName"; cmd = new SqlCommand(Select); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.Parameters.AddWithValue("@UserName", userName); } conn.Open(); using (SqlDataReader oReader = cmd.ExecuteReader()) { while (oReader.Read()) { DataObject.SysUser obj = new DataObject.SysUser(); obj.ID = Int32.Parse(oReader["ID"].ToString()); obj.UserName = oReader["UserName"].ToString(); obj.Password = oReader["Password"].ToString(); obj.Email = oReader["Email"].ToString(); obj.DeptId = Int32.Parse(oReader["DeptId"].ToString()); obj.OrgId = Int32.Parse(oReader["OrgId"].ToString()); obj.Create_User = oReader["Create_User"].ToString(); if (oReader["Create_Date"].ToString() != "" && oReader["Create_Date"].ToString() != null) { String createDate = String.Format("{0:dd/MM/yyyy}", oReader["Create_Date"].ToString()); obj.Create_Date = DateTime.Parse(createDate); } lstSysUser.Add(obj); } } conn.Close(); return(lstSysUser); }
public void Update(DataObject.SysUser obj) { Servies.SysUserServies.UpdateData(obj); }
public void Insert(DataObject.SysUser obj) { Servies.SysUserServies.InsertData(obj); }