public int CreateCompany(CompanyEntity entity)
 {
     int entityid = 0;
     base.UseTran((tran) =>
     {
         var cmd = GetCreateCompanyCommand(this.Database, entity);
         base.Database.ExecuteNonQuery(cmd, tran);
         entityid = (int)base.Database.GetParameterValue(cmd, "CompanyId");
     });
     return entityid;
 }
 public static DbCommand GetUpdateProductCommand(Database database, CompanyEntity entity)
 {
     DbCommand cmd = database.GetStoredProcCommand("P_UpdateCompany");
     #region 参数赋值
     database.AddInParameter(cmd, "CompanyId", DbType.Int32, entity.CompanyId);
     database.AddInParameter(cmd, "CompanyNo", DbType.String, entity.CompanyNo);
     database.AddInParameter(cmd, "CompanyName", DbType.String, entity.CompanyName);
     database.AddInParameter(cmd, "Address", DbType.String, entity.Address);
     database.AddInParameter(cmd, "Tel", DbType.String, entity.Tel);
     database.AddInParameter(cmd, "Fax", DbType.String, entity.Fax);
     database.AddInParameter(cmd, "PostCode", DbType.String, entity.PostCode);
     database.AddInParameter(cmd, "EMail", DbType.String, entity.EMail);
     database.AddInParameter(cmd, "Person", DbType.String, entity.Person);
     database.AddInParameter(cmd, "BankAndAcount", DbType.String, entity.BankAndAcount);
     database.AddInParameter(cmd, "TaxNumber", DbType.String, entity.TaxNumber);
     database.AddInParameter(cmd, "ARTotal", DbType.Decimal, entity.ARTotal);
     database.AddInParameter(cmd, "APTotal", DbType.Decimal, entity.APTotal);
     database.AddInParameter(cmd, "Remark", DbType.String, entity.Remark);
     database.AddInParameter(cmd, "Password", DbType.String, entity.Password);
     database.AddInParameter(cmd, "Enable", DbType.Boolean, entity.Enable);
     database.AddInParameter(cmd, "LastModifyId", DbType.String, entity.LastModifyId);
     #endregion
     return cmd;
 }
 private static CompanyEntity DataRowToEntity(DataRow row)
 {
     if (row == null)
         return null;
     var result = new CompanyEntity()
     {
         CompanyId = (int)(row["CompanyId"]),
         CompanyNo = (string)(row["CompanyNo"]),
         CompanyName = (string)(row["CompanyName"]),
         Address = (string)(row["Address"]),
         Tel = (string)(row["Tel"]),
         Fax = (string)(row["Fax"]),
         PostCode = (string)(row["PostCode"]),
         EMail = (string)(row["EMail"]),
         Person = (string)(row["Person"]),
         BankAndAcount = (string)(row["BankAndAcount"]),
         TaxNumber = (string)(row["TaxNumber"]),
         ARTotal = (decimal)(row["ARTotal"]),
         APTotal = (decimal)(row["APTotal"]),
         Remark = (string)(row["Remark"]),
         CreateId = (string)(row["CreateId"]),
         CreateDate = (DateTime)(row["CreateDate"]),
         LastModifyId = (string)(row["LastModifyId"]),
         LastModifyDate = (DateTime)(row["LastModifyDate"]),
         Password = (string)(row["Password"]),
         Enable = (bool)(row["Enable"]),
         PId = (int)(row["PId"]),
         Level_Path = (string)(row["Level_Path"]),
         Level_Num = (int)(row["Level_Num"]),
         Level_Total = (int)(row["Level_Total"]),
         Level_Deep = (int)(row["Level_Deep"]),
     };
     return result;
 }
 private static CompanyEntity[] DataTableToEntitys(DataTable dt)
 {
     if (dt == null)
         return null;
     var results = new CompanyEntity[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         results[i] = CompanyService.DataRowToEntity(dt.Rows[i]);
     }
     return results;
 }
 public void UpdateCompany(CompanyEntity entity)
 {
     base.UseTran((tran) =>
     {
         var cmd = GetUpdateProductCommand(this.Database, entity);
         base.Database.ExecuteNonQuery(cmd, tran);
     });
 }