示例#1
0
 /// <summary>
 /// Xóa một entity
 /// </summary>
 public int Delete(int id)
 {
     using (dl)
     {
         return(dl.Delete(id));
     }
 }
示例#2
0
 /// <summary>
 /// Xóa dòng dữ liệu hiện tại
 /// </summary>
 /// <returns></returns>
 public bool Delete()
 {
     //if (oDLBase.Delete(Convert.ToInt32(MasterRow[strMasterPrimarykey].ToString())))
     //{
     //    DataSource.Tables[strTableMasterName].Rows.Remove(MasterRow);
     //    DataSource.AcceptChanges();
     //    return true;
     //}
     //else
     //{
     //    return false;
     //}
     using (var cnn = oDLBase.DataConnection)
     {
         MySqlTransaction ts        = null;
         bool             blnResult = false;
         try
         {
             if (cnn.State == ConnectionState.Closed)
             {
                 cnn.Open();
             }
             ts        = cnn.BeginTransaction();
             blnResult = PrepareDelete(ts);
             if (blnResult && oDLBase.Delete(Convert.ToInt32(MasterRow[strMasterPrimarykey].ToString()), ts))
             {
                 blnResult = CompleteDelete(ts);
             }
             else
             {
                 blnResult = false;
             }
             if (blnResult)
             {
                 ts.Commit();
                 DataSource.Tables[strTableMasterName].Rows.Remove(MasterRow);
                 DataSource.AcceptChanges();
             }
             else
             {
                 ts.Rollback();
             }
         }
         catch (Exception ex)
         {
             ts.Rollback();
             throw ex;
         }
         finally
         {
             if (ts != null)
             {
                 ts.Dispose();
             }
             cnn.Close();
         }
         return(blnResult);
     }
 }
示例#3
0
 // POST api/<controller>
 public HttpResponseMessage PostValue([FromBody()] Dictionary <string, string> values)
 {
     if (values["action"] == "delete")
     {
         base.SetParamsAndSettings();
         DLBase defaultList = GetDLObject(settings, values);
         if (values != null)
         {
             settings.VariableKey1 = values["variableKey1"];
             settings.VariableKey2 = values["variableKey2"];
             settings.VariableKey3 = values["variableKey3"];
             settings.VariableKey4 = values["variableKey4"];
             defaultList.Delete();
         }
         return(GetContent(settings, defaultList));
     }
     return(GetEmptyContent());
 }
示例#4
0
        protected virtual void Delete()
        {
            DLBase dal = GetMapper();

            dal.Delete(this);
        }