Пример #1
0
 public UserSecurity UpdateData(UserSecurity obj)
 {
     try
     {
         string     query = obj.ObjectToQuery <UserSecurity>("update");
         SqlCommand cmd   = new SqlCommand(query, mySQLDBConnect.connection);
         mySQLDBConnect.OpenConnection();
         cmd.ExecuteNonQuery();
         mySQLDBConnect.CloseConnection();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     return(obj);
 }
Пример #2
0
 public UserSecurity PostData(UserSecurity obj)
 {
     try
     {
         string     query = obj.ObjectToQuery <UserSecurity>("insert") + "SELECT SCOPE_IDENTITY()";
         SqlCommand cmd   = new SqlCommand(query, mySQLDBConnect.connection);
         mySQLDBConnect.OpenConnection();
         // cmd.ExecuteNonQuery();
         obj.Id = Convert.ToInt32(cmd.ExecuteScalar());
         mySQLDBConnect.CloseConnection();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     return(obj);
 }
Пример #3
0
        public Int32 DeleteBulkData(List <Int32> Ids)
        {
            Int32 result = 0;

            try
            {
                string query = "";
                Ids.ForEach(Id =>
                {
                    UserSecurity obj = GetSingle(Id);
                    query           += obj.ObjectToQuery <UserSecurity>("update");
                });
                SqlCommand cmd = new SqlCommand(query, mySQLDBConnect.connection);
                mySQLDBConnect.OpenConnection();
                result = cmd.ExecuteNonQuery();
                mySQLDBConnect.CloseConnection();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(result);
        }