Esempio n. 1
0
 //Delete an Object in database dmTinhThanh
 public static int Delete(dmTinhThanh_Object DeletingObject)
 {
     List<SqlParameter> paralist = new List<SqlParameter>();
     string DeleteQuery =
     @"Delete [dmTinhThanh]
     Where Id= @Id";
     paralist.Add(new SqlParameter("Id", DeletingObject.Id));
     return commonDatabase.ExecuteNonQuerySQL(clsConnectionString.GetConnectionString(), DeleteQuery, paralist);
 }
Esempio n. 2
0
 //Save changes of an Object to database dmTinhThanh
 public static int SaveChanged(dmTinhThanh_Object UpdatingObject)
 {
     List<SqlParameter> paralist = new List<SqlParameter>();
     string UpdateQuery =
     @"Update dmTinhThanh SET
        TenTinhThanh= @TenTinhThanh
     Where Id= @Id";
     paralist.Add(new SqlParameter("Id", UpdatingObject.Id));
     paralist.Add(new SqlParameter("TenTinhThanh", UpdatingObject.TenTinhThanh));
     return commonDatabase.ExecuteNonQuerySQL(clsConnectionString.GetConnectionString(), UpdateQuery, paralist);
 }
Esempio n. 3
0
 //Get an Object of dmTinhThanh
 public static dmTinhThanh_Object GetObject(int _Id)
 {
     List<SqlParameter> paralist = new List<SqlParameter>();
     dmTinhThanh_Object newObject = new dmTinhThanh_Object();
     string SelectQuery = "Select * from [dmTinhThanh] where (1=1) and [Id]= @Id";
     paralist.Add(new SqlParameter("Id", _Id));
     DataTable tb = commonDatabase.GetSQLDataTable(clsConnectionString.GetConnectionString(), SelectQuery, paralist);
     if (tb.Rows.Count < 1) return null;
     DataRow row = tb.Rows[0];
     newObject.Id = (int)row["Id"];
     if (row["TenTinhThanh"].ToString() != "") newObject.TenTinhThanh = (string)row["TenTinhThanh"];
     return newObject;
 }
Esempio n. 4
0
 //Select dmTinhThanh
 public static List<dmTinhThanh_Object> SelectAll()
 {
     string SelectQuery = @"Select * from [dmTinhThanh]";
     List<dmTinhThanh_Object> result = new List<dmTinhThanh_Object>();
     DataTable tb = commonDatabase.GetSQLDataTable(clsConnectionString.GetConnectionString(), SelectQuery);
     foreach (DataRow row in tb.Rows)
     {
         dmTinhThanh_Object newObject = new dmTinhThanh_Object();
         newObject.Id = (int)row["Id"];
         if (row["TenTinhThanh"].ToString() != "") newObject.TenTinhThanh = (string)row["TenTinhThanh"];
         result.Add(newObject);
     }
     return result;
 }
Esempio n. 5
0
 //Insert dmTinhThanh
 public static int Insert(dmTinhThanh_Object newObject)
 {
     string InsertQuery = "Insert Into [dmTinhThanh]";
     List<SqlParameter> paralist = new List<SqlParameter>();
     string _val = "", _para = "";
     _val += "Id, "; _para += "@Id, ";
     paralist.Add(new SqlParameter("Id", newObject.Id));
     if (newObject.TenTinhThanh != null)
     {
         _val += "TenTinhThanh, "; _para += "@TenTinhThanh, ";
         paralist.Add(new SqlParameter("TenTinhThanh", newObject.TenTinhThanh));
     }
     InsertQuery += "(" + _val + ") Values (" + _para + ")";
     InsertQuery = InsertQuery.Replace(", )", ")");
     return commonDatabase.ExecuteNonQuerySQL(clsConnectionString.GetConnectionString(), InsertQuery, paralist);
 }