public static int GetFixedPriceProdCount(Int64 comp_xid, string filter) { try { string sqlStmt = @"SELECT COUNT(*) FROM b2b.b2d_fixedprice_prod a JOIN b2b.b2d_company b ON a.company_xid=b.xid WHERE a.company_xid=:company_xid {FILTER}"; sqlStmt = sqlStmt.Replace("{FILTER}", !string.IsNullOrEmpty(filter) ? filter : string.Empty); NpgsqlParameter[] sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("company_xid", comp_xid) }; int total_count = Convert.ToInt32(NpgsqlHelper.ExecuteScalar(Website.Instance.SqlConnectionString, CommandType.Text, sqlStmt, sqlParams)); return(total_count); } catch (Exception ex) { Website.Instance.logger.FatalFormat("{0}.{1}", ex.Message, ex.StackTrace); throw ex; } }
// 新增分銷商主帳號 public static string InsAccount(NpgsqlTransaction trans, RegisterModel reg, object comp_xid) { try { string sqlStmt = @"INSERT INTO b2b.b2d_account(company_xid, account_type, enable, password, name_last, name_first, gender_title, email, tel, crt_user, crt_datetime, job_title, user_uuid) VALUES (:company_xid, :account_type, :enable, :password,:name_last, :name_first, :gender_title, :email, :tel, :crt_user, now(), :job_title, :user_uuid); SELECT currval('b2b.b2d_account_xid_seq') AS new_comp_xid ;"; NpgsqlParameter[] sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("company_xid", comp_xid), new NpgsqlParameter("account_type", "01"), //帳號權限(00一般/01管理者) new NpgsqlParameter("enable", false), //是否有效(true/false) new NpgsqlParameter("password", reg.PASSWORD), new NpgsqlParameter("gender_title", reg.GENDER_TITLE), new NpgsqlParameter("name_last", reg.NAME_LAST), new NpgsqlParameter("name_first", reg.NAME_FIRST), new NpgsqlParameter("job_title", reg.JOB_TITLE), new NpgsqlParameter("email", reg.EMAIL), new NpgsqlParameter("tel", reg.TEL), new NpgsqlParameter("crt_user", "system"), new NpgsqlParameter("user_uuid", reg.USER_UUID) }; var new_xid = NpgsqlHelper.ExecuteScalar(trans, CommandType.Text, sqlStmt, sqlParams); return(new_xid.ToString()); } catch (Exception ex) { Website.Instance.logger.FatalFormat("{0}.{1}", ex.Message, ex.StackTrace); throw ex; } }
/// <summary> /// Inserts a row in the i7_sflexi_items table. Returns new integer id. /// </summary> /// <param name="siteGuid"> siteGuid </param> /// <param name="featureGuid"> featureGuid </param> /// <param name="moduleGuid"> moduleGuid </param> /// <param name="moduleID"> moduleID </param> /// <param name="definitionGuid"> definitionGuid </param> /// <param name="itemGuid"> itemGuid </param> /// <param name="sortOrder"> sortOrder </param> /// <param name="createdUtc"> createdUtc </param> /// <param name="lastModUtc"> lastModUtc </param> /// <returns>int</returns> public static int Create( Guid siteGuid, Guid featureGuid, Guid moduleGuid, int moduleID, Guid definitionGuid, Guid itemGuid, int sortOrder, DateTime createdUtc, DateTime lastModUtc, string viewRoles, string editRoles) { var sqlCommand = @" insert into i7_sflexi_items (itemguid ,siteguid ,featureguid ,moduleguid ,moduleid ,definitionguid ,sortorder ,createdutc ,lastmodutc ,viewroles ,editroles) values (:itemguid ,:siteguid ,:featureguid ,:moduleguid ,:moduleid ,:definitionguid ,:sortorder ,:createdutc ,:lastmodutc ,:viewroles ,:editroles) returning itemid;" ; var sqlParams = new List <NpgsqlParameter> { new NpgsqlParameter(":itemguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = itemGuid }, new NpgsqlParameter(":siteguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = siteGuid }, new NpgsqlParameter(":featureguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = featureGuid }, new NpgsqlParameter(":moduleguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = moduleGuid }, new NpgsqlParameter(":moduleid", NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = moduleID }, new NpgsqlParameter(":definitionguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = definitionGuid }, new NpgsqlParameter(":sortorder", NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = sortOrder }, new NpgsqlParameter(":createdutc", NpgsqlDbType.Timestamp) { Direction = ParameterDirection.Input, Value = createdUtc }, new NpgsqlParameter(":lastmodutc", NpgsqlDbType.Timestamp) { Direction = ParameterDirection.Input, Value = lastModUtc }, new NpgsqlParameter(":viewroles", NpgsqlDbType.Varchar) { Direction = ParameterDirection.Input, Value = viewRoles }, new NpgsqlParameter(":editroles", NpgsqlDbType.Varchar) { Direction = ParameterDirection.Input, Value = editRoles } }; return(Convert.ToInt32(NpgsqlHelper.ExecuteScalar( ConnectionString.GetWriteConnectionString(), CommandType.Text, sqlCommand, sqlParams.ToArray()).ToString())); }
// 分銷商註冊 public static void InsCompany(RegisterModel reg) { NpgsqlConnection conn = new NpgsqlConnection(Website.Instance.SqlConnectionString); NpgsqlTransaction trans = null; try { conn.Open(); trans = conn.BeginTransaction(); string sqlStmt = @"INSERT INTO b2b.b2d_company( status, comp_coop_mode, payment_type, manager_account_xid, comp_name, comp_url, comp_license, comp_license_2, comp_country, comp_locale, comp_currency, comp_invoice, comp_tel_country_code, comp_tel, contact_user_email, comp_address, charge_man_first, charge_man_last, contact_user, crt_user, crt_datetime, charge_man_gender, comp_timezone) VALUES (:status, :comp_coop_mode, :payment_type, :manager_account_xid, :comp_name, :comp_url, :comp_license, :comp_license_2, :comp_country, :comp_locale, :comp_currency, :comp_invoice, :comp_tel_country_code, :comp_tel, :contact_user_email, :comp_address, :charge_man_first, :charge_man_last, :contact_user, :crt_user, now(), :charge_man_gender, :comp_timezone); SELECT currval('b2b.b2d_company_xid_seq') AS new_comp_xid ; "; NpgsqlParameter[] sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("status", "00"), //審核狀態(00已申請/01審核中/02待補件/03已核准/04未核准) new NpgsqlParameter("comp_coop_mode", "02"), //合作方式(00全開/01串接API/02Web平台) new NpgsqlParameter("payment_type", "01"), //付款方式(01逐筆結/02額度付款) new NpgsqlParameter("manager_account_xid", 1), new NpgsqlParameter("comp_name", reg.COMPANY_NAME), new NpgsqlParameter("comp_url", reg.URL), new NpgsqlParameter("comp_license", reg.LICENCSE_1), new NpgsqlParameter("comp_license_2", reg.LICENCSE_2), new NpgsqlParameter("comp_locale", reg.LOCALE), new NpgsqlParameter("comp_currency", reg.CURRENCY), new NpgsqlParameter("comp_invoice", reg.INVOICE), new NpgsqlParameter("comp_country", reg.COUNTRY_CODE), new NpgsqlParameter("comp_tel_country_code", reg.TEL_CODE), new NpgsqlParameter("comp_tel", reg.TEL), new NpgsqlParameter("contact_user_email", reg.EMAIL), new NpgsqlParameter("comp_address", reg.ADDRESS), new NpgsqlParameter("charge_man_first", reg.NAME_FIRST), new NpgsqlParameter("charge_man_last", reg.NAME_LAST), new NpgsqlParameter("contact_user", string.Empty), new NpgsqlParameter("crt_user", "system"), new NpgsqlParameter("charge_man_gender", reg.GENDER_TITLE), new NpgsqlParameter("comp_timezone", Convert.ToInt32(reg.TIMEZONE)) }; var new_comp_xid = NpgsqlHelper.ExecuteScalar(trans, CommandType.Text, sqlStmt, sqlParams); var new_acc_xid = InsAccount(trans, reg, new_comp_xid); UpdManagerXid(trans, new_comp_xid, new_acc_xid); trans.Commit(); conn.Close(); } catch (Exception ex) { Website.Instance.logger.FatalFormat("{0}.{1}", ex.Message, ex.StackTrace); if (trans != null) { trans.Rollback(); } conn.Close(); throw ex; } }
/// <summary> /// Inserts a row in the i7_sflexi_items table. Returns new integer id. /// </summary> /// <param name="siteGuid"> siteGuid </param> /// <param name="featureGuid"> featureGuid </param> /// <param name="moduleGuid"> moduleGuid </param> /// <param name="moduleID"> moduleID </param> /// <param name="definitionGuid"> definitionGuid </param> /// <param name="itemGuid"> itemGuid </param> /// <param name="sortOrder"> sortOrder </param> /// <param name="createdUtc"> createdUtc </param> /// <param name="lastModUtc"> lastModUtc </param> /// <returns>int</returns> public static int Create( Guid siteGuid, Guid featureGuid, Guid moduleGuid, int moduleID, Guid definitionGuid, Guid itemGuid, int sortOrder, DateTime createdUtc, DateTime lastModUtc) { StringBuilder sqlCommand = new StringBuilder(); sqlCommand.AppendFormat("insert into i7_sflexi_items ({0}) values ({1}) returning itemid;" , @"itemguid ,siteguid ,featureguid ,moduleguid ,moduleid ,definitionguid ,sortorder ,createdutc ,lastmodutc" , @":itemguid ,:siteguid ,:featureguid ,:moduleguid ,:moduleid ,:definitionguid ,:sortorder ,:createdutc ,:lastmodutc" ); var sqlParams = new List <NpgsqlParameter> { new NpgsqlParameter(":itemguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = itemGuid }, new NpgsqlParameter(":siteguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = siteGuid }, new NpgsqlParameter(":featureguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = featureGuid }, new NpgsqlParameter(":moduleguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = moduleGuid }, new NpgsqlParameter(":moduleid", NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = moduleID }, new NpgsqlParameter(":definitionguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = definitionGuid }, new NpgsqlParameter(":sortorder", NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = sortOrder }, new NpgsqlParameter(":createdutc", NpgsqlDbType.Timestamp) { Direction = ParameterDirection.Input, Value = createdUtc }, new NpgsqlParameter(":lastmodutc", NpgsqlDbType.Timestamp) { Direction = ParameterDirection.Input, Value = lastModUtc } }; return(Convert.ToInt32(NpgsqlHelper.ExecuteScalar( ConnectionString.GetWriteConnectionString(), CommandType.Text, sqlCommand.ToString(), sqlParams.ToArray()).ToString())); }
/// <summary> /// Inserts a row in the mp_MediaTrack table. /// </summary> /// <param name="playerID">The ID of the player to which the Media Track is being added.</param> /// <param name="trackType">The type of the track.</param> /// <param name="trackOrder">The order position of the Media Track.</param> /// <param name="name">The name of the Media Track.</param> /// <param name="artist">The artist of the Media Track.</param> /// <param name="userGuid">The Guid of the user who added the Media Track.</param> /// <returns>The ID of the Media Track in the doan_MediaTracks table.</returns> public static int Insert( int playerId, string trackType, int trackOrder, string name, string artist, Guid userGuid) { StringBuilder sqlCommand = new StringBuilder(); sqlCommand.Append("INSERT INTO mp_mediatrack ("); sqlCommand.Append("playerid, "); sqlCommand.Append("tracktype, "); sqlCommand.Append("trackorder, "); sqlCommand.Append("name, "); sqlCommand.Append("artist, "); sqlCommand.Append("createddate, "); sqlCommand.Append("userguid )"); sqlCommand.Append(" VALUES ("); sqlCommand.Append(":playerid, "); sqlCommand.Append(":tracktype, "); sqlCommand.Append(":trackorder, "); sqlCommand.Append(":name, "); sqlCommand.Append(":artist, "); sqlCommand.Append(":createddate, "); sqlCommand.Append(":userguid )"); sqlCommand.Append(";"); sqlCommand.Append(" SELECT CURRVAL('mp_mediatrackid_seq');"); NpgsqlParameter[] arParams = new NpgsqlParameter[7]; arParams[0] = new NpgsqlParameter("playerid", NpgsqlTypes.NpgsqlDbType.Integer); arParams[0].Direction = ParameterDirection.Input; arParams[0].Value = playerId; arParams[1] = new NpgsqlParameter("tracktype", NpgsqlTypes.NpgsqlDbType.Varchar, 10); arParams[1].Direction = ParameterDirection.Input; arParams[1].Value = trackType; arParams[2] = new NpgsqlParameter("trackorder", NpgsqlTypes.NpgsqlDbType.Integer); arParams[2].Direction = ParameterDirection.Input; arParams[2].Value = trackOrder; arParams[3] = new NpgsqlParameter("name", NpgsqlTypes.NpgsqlDbType.Varchar, 100); arParams[3].Direction = ParameterDirection.Input; arParams[3].Value = name; arParams[4] = new NpgsqlParameter("artist", NpgsqlTypes.NpgsqlDbType.Varchar, 100); arParams[4].Direction = ParameterDirection.Input; arParams[4].Value = artist; arParams[5] = new NpgsqlParameter("createddate", NpgsqlTypes.NpgsqlDbType.Timestamp); arParams[5].Direction = ParameterDirection.Input; arParams[5].Value = DateTime.UtcNow; arParams[6] = new NpgsqlParameter("userguid", NpgsqlTypes.NpgsqlDbType.Char, 36); arParams[6].Direction = ParameterDirection.Input; arParams[6].Value = userGuid.ToString(); int newID = Convert.ToInt32(NpgsqlHelper.ExecuteScalar( ConnectionString.GetWriteConnectionString(), CommandType.Text, sqlCommand.ToString(), arParams)); return(newID); }
// 匯入商品套餐與價格 public static void ImportPackage(Areas.KKday.Models.DataModel.FixedPrice.ImportPackage pkg, string crt_user) { NpgsqlConnection conn = new NpgsqlConnection(Website.Instance.SqlConnectionString); NpgsqlTransaction trans = null; string sqlStmt; NpgsqlParameter[] sqlParams = null; try { conn.Open(); trans = conn.BeginTransaction(); foreach (var item in pkg.packages) { sqlStmt = @"INSERT INTO b2b.b2d_fixedprice_prod_pkg(prod_xid, pkg_no, pkg_name, online_sdate, online_edate, crt_user, crt_datetime) VAlUES (:prod_xid, :pkg_no, :pkg_name, :online_sdate, :online_edate, :crt_user, now()); SELECT currval('b2b.b2d_fixedprice_prod_pkg_xid_seq') AS new_pkg_xid; "; sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("prod_xid", pkg.PROD_XID), new NpgsqlParameter("pkg_no", item.PKG_NO), new NpgsqlParameter("pkg_name", item.PKG_NAME), new NpgsqlParameter("online_sdate", pkg.S_DATE), new NpgsqlParameter("online_edate", pkg.E_DATE), new NpgsqlParameter("crt_user", crt_user) }; // 新增到 b2d_fixedprice_prod_pkg, 並取得序號 var new_pkg_xid = NpgsqlHelper.ExecuteScalar(trans, CommandType.Text, sqlStmt, sqlParams); foreach (var price in item.prices) { sqlStmt = @"INSERT INTO b2b.b2d_fixedprice_pkg_price(pkg_xid, price_cond, price, crt_user, crt_datetime) VALUES (:pkg_xid, :price_cond, :price, :crt_user, now())"; sqlParams = new NpgsqlParameter[] { new NpgsqlParameter("pkg_xid", new_pkg_xid), new NpgsqlParameter("price_cond", price.COND), new NpgsqlParameter("price", price.PRICE), new NpgsqlParameter("crt_user", crt_user) }; // 新增到 b2d_fixedprice_pkg_price NpgsqlHelper.ExecuteNonQuery(trans, CommandType.Text, sqlStmt, sqlParams); } } trans.Commit(); conn.Close(); } catch (Exception ex) { Website.Instance.logger.FatalFormat("{0}.{1}", ex.Message, ex.StackTrace); if (trans != null) { trans.Rollback(); } conn.Close(); throw ex; } }
/// <summary> /// Updates a row in the i7_sflexi_fields table. Returns true if row updated. /// </summary> public static bool Update( Guid siteGuid, Guid featureGuid, Guid definitionGuid, Guid fieldGuid, string definitionName, string name, string label, string defaultValue, string controlType, string controlSrc, int sortOrder, string helpKey, bool required, string requiredMessageFormat, string regex, string regexMessageFormat, string token, string preTokenString, string postTokenString, string preTokenStringWhenTrue, string postTokenStringWhenTrue, string preTokenStringWhenFalse, string postTokenStringWhenFalse, bool searchable, string editPageControlWrapperCssClass, string editPageLabelCssClass, string editPageControlCssClass, bool datePickerIncludeTimeForDate, bool datePickerShowMonthList, bool datePickerShowYearList, string datePickerYearRange, string imageBrowserEmptyUrl, //string iSettingControlSettings, string options, bool checkBoxReturnBool, string checkBoxReturnValueWhenTrue, string checkBoxReturnValueWhenFalse, string dateFormat, string textBoxMode, string attributes, bool isDeleted, bool isGlobal, string viewRoles, string editRoles) { StringBuilder sqlCommand = new StringBuilder(); sqlCommand.AppendFormat("update i7_sflexi_fields set {0} where fieldguid = :fieldguid;" , @"siteguid = :siteguid ,featureguid = :featureguid ,definitionguid = :definitionguid ,definitionname = :definitionname ,name = :name ,label = :label ,defaultvalue = :defaultvalue ,controltype = :controltype ,controlsrc = :controlsrc ,sortorder = :sortorder ,helpkey = :helpkey ,required = :required ,requiredmessageformat = :requiredmessageformat ,regex = :regex ,regexmessageformat = :regexmessageformat ,token = :token ,pretokenstring = :pretokenstring ,posttokenstring = :posttokenstring ,pretokenstringwhentrue = :pretokenstringwhentrue ,posttokenstringwhentrue = :posttokenstringwhentrue ,pretokenstringwhenfalse = :pretokenstringwhenfalse ,posttokenstringwhenfalse = :posttokenstringwhenfalse ,searchable = :searchable ,editpagecontrolwrappercssclass = :editpagecontrolwrappercssclass ,editpagelabelcssclass = :editpagelabelcssclass ,editpagecontrolcssclass = :editpagecontrolcssclass ,datepickerincludetimefordate = :datepickerincludetimefordate ,datepickershowmonthlist = :datepickershowmonthlist ,datepickershowyearlist = :datepickershowyearlist ,datepickeryearrange = :datepickeryearrange ,imagebrowseremptyurl = :imagebrowseremptyurl ,options = :options ,checkboxreturnbool = :checkboxreturnbool ,checkboxreturnvaluewhentrue = :checkboxreturnvaluewhentrue ,checkboxreturnvaluewhenfalse = :checkboxreturnvaluewhenfalse ,dateformat = :dateformat ,textboxmode = :textboxmode ,attributes = :attributes ,isdeleted = :isdeleted ,isglobal = :isglobal ,viewroles = :viewroles ,editroles = :editroles" ); var sqlParams = new List <NpgsqlParameter> { new NpgsqlParameter(":siteguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = siteGuid }, new NpgsqlParameter(":featureguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = featureGuid }, new NpgsqlParameter(":definitionguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = definitionGuid }, new NpgsqlParameter(":fieldguid", NpgsqlDbType.Uuid) { Direction = ParameterDirection.Input, Value = fieldGuid }, new NpgsqlParameter(":definitionname", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = definitionName }, new NpgsqlParameter(":name", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = name }, new NpgsqlParameter(":label", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = label }, new NpgsqlParameter(":defaultvalue", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = defaultValue }, new NpgsqlParameter(":controltype", NpgsqlDbType.Varchar, 16) { Direction = ParameterDirection.Input, Value = controlType }, new NpgsqlParameter(":controlsrc", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = controlSrc }, new NpgsqlParameter(":sortorder", NpgsqlDbType.Integer) { Direction = ParameterDirection.Input, Value = sortOrder }, new NpgsqlParameter(":helpkey", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = helpKey }, new NpgsqlParameter(":required", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = required }, new NpgsqlParameter(":requiredmessageformat", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = requiredMessageFormat }, new NpgsqlParameter(":regex", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = regex }, new NpgsqlParameter(":regexmessageformat", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = regexMessageFormat }, new NpgsqlParameter(":token", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = token }, new NpgsqlParameter(":pretokenstring", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = preTokenString }, new NpgsqlParameter(":posttokenstring", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = postTokenString }, new NpgsqlParameter(":pretokenstringwhentrue", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = preTokenStringWhenTrue }, new NpgsqlParameter(":posttokenstringwhentrue", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = postTokenStringWhenTrue }, new NpgsqlParameter(":pretokenstringwhenfalse", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = preTokenStringWhenFalse }, new NpgsqlParameter(":posttokenstringwhenfalse", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = postTokenStringWhenFalse }, new NpgsqlParameter(":searchable", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = searchable }, new NpgsqlParameter(":editpagecontrolwrappercssclass", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = editPageControlWrapperCssClass }, new NpgsqlParameter(":editpagelabelcssclass", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = editPageLabelCssClass }, new NpgsqlParameter(":editpagecontrolcssclass", NpgsqlDbType.Varchar, 50) { Direction = ParameterDirection.Input, Value = editPageControlCssClass }, new NpgsqlParameter(":datepickerincludetimefordate", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = datePickerIncludeTimeForDate }, new NpgsqlParameter(":datepickershowmonthlist", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = datePickerShowMonthList }, new NpgsqlParameter(":datepickershowyearlist", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = datePickerShowYearList }, new NpgsqlParameter(":datepickeryearrange", NpgsqlDbType.Varchar, 10) { Direction = ParameterDirection.Input, Value = datePickerYearRange }, new NpgsqlParameter(":imagebrowseremptyurl", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = imageBrowserEmptyUrl }, new NpgsqlParameter(":options", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = options }, new NpgsqlParameter(":checkboxreturnbool", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = checkBoxReturnBool }, new NpgsqlParameter(":checkboxreturnvaluewhentrue", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = checkBoxReturnValueWhenTrue }, new NpgsqlParameter(":checkboxreturnvaluewhenfalse", NpgsqlDbType.Text) { Direction = ParameterDirection.Input, Value = checkBoxReturnValueWhenFalse }, new NpgsqlParameter(":dateformat", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = dateFormat }, new NpgsqlParameter(":textboxmode", NpgsqlDbType.Varchar, 25) { Direction = ParameterDirection.Input, Value = textBoxMode }, new NpgsqlParameter(":attributes", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = attributes }, new NpgsqlParameter(":isglobal", NpgsqlDbType.Boolean) { Direction = ParameterDirection.Input, Value = isGlobal }, new NpgsqlParameter(":viewroles", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = viewRoles }, new NpgsqlParameter(":editroles", NpgsqlDbType.Varchar, 255) { Direction = ParameterDirection.Input, Value = editRoles } }; int rowsAffected = Convert.ToInt32(NpgsqlHelper.ExecuteScalar( ConnectionString.GetWriteConnectionString(), CommandType.Text, sqlCommand.ToString(), sqlParams.ToArray()).ToString()); return(rowsAffected > 0); }
/// <summary> /// Inserts a row in the doan_MediaPlayers table. /// </summary> /// <param name="moduleID">The ID of the Module</param> /// <param name="playerType">The Player Type.</param> /// <param name="createdDate">The Date the Media Player was created.</param> /// <param name="userGuid">The Guid of the user who created the Media Player.</param> /// <param name="moduleGuid">The Guid of the Module.</param> /// <returns>The ID of the Media Player.</returns> public static int Insert( int moduleId, string playerType, String skin, Guid userGuid, Guid moduleGuid) { StringBuilder sqlCommand = new StringBuilder(); sqlCommand.Append("INSERT INTO mp_mediaplayer ("); sqlCommand.Append("moduleid, "); sqlCommand.Append("playertype, "); sqlCommand.Append("skin, "); sqlCommand.Append("createddate, "); sqlCommand.Append("userguid, "); sqlCommand.Append("moduleguid )"); sqlCommand.Append(" VALUES ("); sqlCommand.Append(":moduleid, "); sqlCommand.Append(":playertype, "); sqlCommand.Append(":skin, "); sqlCommand.Append(":createddate, "); sqlCommand.Append(":userguid, "); sqlCommand.Append(":moduleguid )"); sqlCommand.Append(";"); sqlCommand.Append(" SELECT CURRVAL('mp_mediaplayerid_seq');"); NpgsqlParameter[] arParams = new NpgsqlParameter[6]; arParams[0] = new NpgsqlParameter("moduleid", NpgsqlTypes.NpgsqlDbType.Integer); arParams[0].Direction = ParameterDirection.Input; arParams[0].Value = moduleId; arParams[1] = new NpgsqlParameter("playertype", NpgsqlTypes.NpgsqlDbType.Text, 10); arParams[1].Direction = ParameterDirection.Input; arParams[1].Value = playerType; arParams[2] = new NpgsqlParameter("skin", NpgsqlTypes.NpgsqlDbType.Text, 50); arParams[2].Direction = ParameterDirection.Input; arParams[2].Value = skin; arParams[3] = new NpgsqlParameter("createddate", NpgsqlTypes.NpgsqlDbType.Timestamp); arParams[3].Direction = ParameterDirection.Input; arParams[3].Value = DateTime.UtcNow; arParams[4] = new NpgsqlParameter("userguid", NpgsqlTypes.NpgsqlDbType.Char, 36); arParams[4].Direction = ParameterDirection.Input; arParams[4].Value = userGuid.ToString(); arParams[5] = new NpgsqlParameter("moduleguid", NpgsqlTypes.NpgsqlDbType.Char, 36); arParams[5].Direction = ParameterDirection.Input; arParams[5].Value = moduleGuid.ToString(); int newID = Convert.ToInt32(NpgsqlHelper.ExecuteScalar( ConnectionString.GetWriteConnectionString(), CommandType.Text, sqlCommand.ToString(), arParams)); return(newID); }