public static int TemplateInsertUpdate(Templates objTemp) {int result = -1; try { SqlParameter[] prams = null; using (DbManager db = DbManager.GetDbManager()) { List<SqlParameter> param = new List<SqlParameter>(); param.Add(db.MakeInParam("@Templateid", SqlDbType.Int, 0, objTemp.Templateid)); param.Add(db.MakeInParam("@Organizationid", SqlDbType.Int, 0, objTemp.OrganizationId)); param.Add(db.MakeInParam("@Name", SqlDbType.NVarChar, 1000, objTemp.Name)); param.Add(db.MakeInParam("@TemplateTypeID", SqlDbType.Int, 0, objTemp.TemplateTypeID)); param.Add(db.MakeInParamWithoutFormat("@Body", SqlDbType.NVarChar, 10000, objTemp.Body)); param.Add(db.MakeInParam("@IsActive", SqlDbType.Bit, 0, objTemp.IsActive)); param.Add(db.MakeInParam("@IsAdmin", SqlDbType.Bit, 0, objTemp.IsAdmin)); if (objTemp.CreatedBy == 0) param.Add(db.MakeInParam("@CreatedBy", SqlDbType.Int, 0, DBNull.Value)); else param.Add(db.MakeInParam("@CreatedBy", SqlDbType.Int, 0, objTemp.CreatedBy)); if (objTemp.ModifiedBy == 0) param.Add(db.MakeInParam("@ModifiedBy", SqlDbType.Int, 0, DBNull.Value)); else param.Add(db.MakeInParam("@ModifiedBy", SqlDbType.Int, 0, objTemp.ModifiedBy)); if (objTemp.DateCreated == DateTime.MinValue) param.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, DBNull.Value)); else param.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, objTemp.DateCreated)); if (objTemp.DateModified == DateTime.MinValue) param.Add(db.MakeInParam("@DateModified", SqlDbType.DateTime, 0, DBNull.Value)); else param.Add(db.MakeInParam("@DateModified", SqlDbType.DateTime, 0, objTemp.DateModified)); param.Add(db.MakeInParam("@Isprimary", SqlDbType.Bit, 0, objTemp.IsPrimary)); param.Add(db.MakeInParam("@InvoiceType", SqlDbType.Int, 0, objTemp.InvoiceType)); result = db.RunProc("up_Template_insertupdate", param.ToArray()); } } catch(Exception ex) { new SqlLog().InsertSqlLog(0, "Templates.TemplateInsertUpdate", ex); } return result; }
public static int TemplateInsertUpdate(Templates objTemp) { int result = -1; try { SqlParameter[] prams = null; using (DbManager db = DbManager.GetDbManager()) { List <SqlParameter> param = new List <SqlParameter>(); param.Add(db.MakeInParam("@Templateid", SqlDbType.Int, 0, objTemp.Templateid)); param.Add(db.MakeInParam("@Organizationid", SqlDbType.Int, 0, objTemp.OrganizationId)); param.Add(db.MakeInParam("@Name", SqlDbType.NVarChar, 1000, objTemp.Name)); param.Add(db.MakeInParam("@TemplateTypeID", SqlDbType.Int, 0, objTemp.TemplateTypeID)); param.Add(db.MakeInParamWithoutFormat("@Body", SqlDbType.NVarChar, 10000, objTemp.Body)); param.Add(db.MakeInParam("@IsActive", SqlDbType.Bit, 0, objTemp.IsActive)); param.Add(db.MakeInParam("@IsAdmin", SqlDbType.Bit, 0, objTemp.IsAdmin)); if (objTemp.CreatedBy == 0) { param.Add(db.MakeInParam("@CreatedBy", SqlDbType.Int, 0, DBNull.Value)); } else { param.Add(db.MakeInParam("@CreatedBy", SqlDbType.Int, 0, objTemp.CreatedBy)); } if (objTemp.ModifiedBy == 0) { param.Add(db.MakeInParam("@ModifiedBy", SqlDbType.Int, 0, DBNull.Value)); } else { param.Add(db.MakeInParam("@ModifiedBy", SqlDbType.Int, 0, objTemp.ModifiedBy)); } if (objTemp.DateCreated == DateTime.MinValue) { param.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, DBNull.Value)); } else { param.Add(db.MakeInParam("@DateCreated", SqlDbType.DateTime, 0, objTemp.DateCreated)); } if (objTemp.DateModified == DateTime.MinValue) { param.Add(db.MakeInParam("@DateModified", SqlDbType.DateTime, 0, DBNull.Value)); } else { param.Add(db.MakeInParam("@DateModified", SqlDbType.DateTime, 0, objTemp.DateModified)); } param.Add(db.MakeInParam("@Isprimary", SqlDbType.Bit, 0, objTemp.IsPrimary)); param.Add(db.MakeInParam("@InvoiceType", SqlDbType.Int, 0, objTemp.InvoiceType)); result = db.RunProc("up_Template_insertupdate", param.ToArray()); } } catch (Exception ex) { new SqlLog().InsertSqlLog(0, "Templates.TemplateInsertUpdate", ex); } return(result); }