//public HttpResponseBase EditPromoShareMaster() //{ // PromoShareMaster query = new PromoShareMaster(); // string json = string.Empty; // try // { // if (!string.IsNullOrEmpty(Request.Params["Epromo_id"])) // { // query.promo_id = Convert.ToInt32(Request.Params["Epromo_id"]); // } // if (!string.IsNullOrEmpty(Request.Params["Epromo_name"])) // { // query.promo_name = Request.Params["Epromo_name"]; // } // if (!string.IsNullOrEmpty(Request.Params["Epromo_desc"])) // { // query.promo_desc = Request.Params["Epromo_desc"]; // } // if (!string.IsNullOrEmpty(Request.Params["Epromo_start"])) // { // query.promo_start = Convert.ToDateTime(Request.Params["Epromo_start"]); // } // if (!string.IsNullOrEmpty(Request.Params["Epromo_end"])) // { // query.promo_end = Convert.ToDateTime(Request.Params["Epromo_end"]); // } // PshareMgr = new PromoShareMasterMgr(mySqlConnectionString); // if (PshareMgr.Update(query) > 0) // { // json = "{success:true}"; // } // else // { // json = "{success:false}"; // } // } // catch (Exception ex) // { // Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); // logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); // logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; // log.Error(logMessage); // json = "{success:false}"; // } // this.Response.Clear(); // this.Response.Write(json); // this.Response.End(); // return this.Response; //} #endregion #region 編輯 public HttpResponseBase updatePromoShareCon() { PromoShareMaster psmQuery = new PromoShareMaster(); PromoShareCondition pscQuery = new PromoShareCondition(); PshareMgr = new PromoShareMasterMgr(mySqlConnectionString); PshareConMgr = new PromoShareConditionMgr(mySqlConnectionString); string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["promo_name"])) { psmQuery.promo_name = Request.Params["promo_name"]; } if (!string.IsNullOrEmpty(Request.Params["promo_desc"])) { psmQuery.promo_desc = Request.Params["promo_desc"]; } if (!string.IsNullOrEmpty(Request.Params["promo_start"])) { psmQuery.promo_start = Convert.ToDateTime(Request.Params["promo_start"]); } if (!string.IsNullOrEmpty(Request.Params["promo_end"])) { psmQuery.promo_end = Convert.ToDateTime(Request.Params["promo_end"]); } if (!string.IsNullOrEmpty(Request.Params["promo_id"])) { psmQuery.promo_id = Convert.ToInt32(Request.Params["promo_id"]); } //判斷如果condition表內無此編號的數據則insert,如果有此編號的數據則update if (PshareMgr.PromoCon(psmQuery) == 0) {//執行新增 InsertIntoPromoShareCon(pscQuery);//插入promo_share_condition;新增入第二個面板 } else {//執行編輯 //編輯第一個面板 PshareMgr.Update(psmQuery); //1編輯第二個面板 promo_share_condition, //2將promo_share_condition表中對應promo_id數據刪除 //3然後再次insert PshareConMgr.Delete(psmQuery.promo_id); InsertIntoPromoShareCon(pscQuery); //PshareConMgr.Update(pscQuery); } json = "{success:true}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase InsertIntoPromoShareMaster() { PromoShareMasterQuery query = new PromoShareMasterQuery(); string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["promo_name"])) { query.promo_name = Request.Params["promo_name"]; } if (!string.IsNullOrEmpty(Request.Params["promo_desc"])) { query.promo_desc = Request.Params["promo_desc"]; } if (!string.IsNullOrEmpty(Request.Params["promo_start"])) { query.promo_start = Convert.ToDateTime(Request.Params["promo_start"]); } if (!string.IsNullOrEmpty(Request.Params["promo_end"])) { query.promo_end = Convert.ToDateTime(Request.Params["promo_end"]); } PshareMgr = new PromoShareMasterMgr(mySqlConnectionString); int PromoId = PshareMgr.Add(query); string strPromoId ="SH"; if (PromoId > 0) { if (PromoId.ToString().Length < 6) { for (int i = 0; i < 6 - PromoId.ToString().Length; i++) { strPromoId += "0"; } } strPromoId += PromoId.ToString(); query = new PromoShareMasterQuery(); query.promo_event_id = strPromoId; query.promo_id = PromoId; query.eventId = true; if (PshareMgr.Update(query) > 0) { json = "{success:'true',strPromoId:'" + strPromoId + "',PromoId:'" + PromoId + "'}"; } else { json = "{success:false}"; } } else { json = "{success:false}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }