public int SaveTwo(PromoPair promopair,PromoPairQuery ppQuery) { try { return _PPairDao.SaveTwo(promopair, ppQuery); } catch (Exception ex) { throw new Exception("PromoPairMgr-->Save-->" + ex.Message, ex); } }
public int Update(PromoPair promopair, PromoPairQuery PPQuery) { try { return _PPairDao.Update(promopair, PPQuery); } catch (Exception ex) { throw new Exception("PromoPairMgr-->Update-->" + ex.Message, ex); } }
public int Save(PromoPair promopair) { try { return _PPairDao.SaveOne(promopair); } catch (Exception ex) { throw new Exception("PromoPairMgr-->Save-->" + ex.Message, ex); } }
public HttpResponseBase PromoPairDelete() { string jsonStr = String.Empty; _promopairMgr = new PromoPairMgr(mySqlConnectionString); PromoPair query = new PromoPair(); if (!String.IsNullOrEmpty(Request.Params["rowid"])) { try { foreach (string rid in Request.Params["rowid"].ToString().Split('|')) { if (!string.IsNullOrEmpty(rid)) { query.id = Convert.ToInt32(rid); _promopairMgr.Delete(query); } } jsonStr = "{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); jsonStr = "{success:false}"; } } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
public HttpResponseBase PromoPairEdit() { string jsonStr = String.Empty; _promopairMgr = new PromoPairMgr(mySqlConnectionString); PromoPair model = new PromoPair(); PromoPair oldermodel = new PromoPair(); PromoPairQuery PPQuery = new PromoPairQuery(); ProductCategory olderpcmodel = new ProductCategory(); PromoPairQuery oldPPQuery = new PromoPairQuery(); if (!String.IsNullOrEmpty(Request.Params["rowid"])) { try { model.id = Convert.ToInt32(Request.Params["rowid"].ToString()); model.category_id = Convert.ToInt32(Request.Params["categoryid"].ToString()); oldermodel = _promopairMgr.GetModelById(model.id); olderpcmodel = _produCateMgr.GetModelById(Convert.ToUInt32(model.category_id)); model.event_name = Request.Params["event_name"].ToString(); model.event_desc = Request.Params["event_desc"].ToString(); model.event_type = oldermodel.event_type; model.vendor_coverage = int.Parse(Request.Params["vendor_coverage"]); #region 會員群組 會員條件 if (Request.Params["group_id"].ToString() != "") { try//group_id { model.group_id = Convert.ToInt32(Request.Params["group_id"].ToString()); } catch (Exception) { model.group_id = oldermodel.group_id; } if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0") { UserCondition uc = new UserCondition(); uc.condition_id = Convert.ToInt32(Request.Params["condition_id"]); if (_ucMgr.Delete(uc) > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false,msg:'user_condition刪除出錯!'}"; this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; } } model.condition_id = 0; } else if (Request.Params["condition_id"].ToString() != "" && Request.Params["condition_id"].ToString() != "0") { try//condition_id { model.condition_id = Convert.ToInt32(Request.Params["condition_id"].ToString()); } catch (Exception) { model.condition_id = oldermodel.condition_id; } model.group_id = 0; } #endregion model.deliver_type = Convert.ToInt32(Request.Params["deliver_id"].ToString()); model.device = Request.Params["device_id"].ToString(); //model.website = Request.Params["side"].ToString(); if (!string.IsNullOrEmpty(Request.Params["side"].ToString()))//修改時傳的值為siteName { Regex reg = new Regex("^([0-9]+,)*[0-9]+$"); if (reg.IsMatch(Request.Params["side"].ToString())) { model.website = Request.Params["side"].ToString();// 將站台改為多選 edit by shuangshuang0420j 20140925 10:08 } else { model.website = oldermodel.website; } } #region 紅+綠 if (Request.Params["price"].ToString() != "") { try//price { model.price = Convert.ToInt32(Request.Params["price"].ToString()); } catch (Exception) { model.price = oldermodel.group_id; } model.discount = 0; } else if (Request.Params["discount"].ToString() != "") { try//discount { model.discount = Convert.ToInt32(Request.Params["discount"].ToString()); } catch (Exception) { model.discount = oldermodel.condition_id; } model.price = 0; } #endregion model.starts = Convert.ToDateTime(Request.Params["starts"].ToString()); model.end = Convert.ToDateTime(Request.Params["end"].ToString()); model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString(); model.modified = DateTime.Now; PPQuery.event_id = CommonFunction.GetEventId(model.event_type, model.id.ToString()); #region 上傳圖片 try { string path = Server.MapPath(xmlPath); SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path); SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format"); SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue"); SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue"); SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME"); SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD"); //擴展名、最小值、最大值 string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value; string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value; string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value; string localPromoPath = imgLocalPath + promoPath;//圖片存儲地址 Random rand = new Random(); int newRand = rand.Next(1000, 9999); FileManagement fileLoad = new FileManagement(); for (int iFile = 0; iFile < Request.Files.Count; iFile++) { HttpPostedFileBase file = Request.Files[iFile]; string fileName = string.Empty;//當前文件名 string fileExtention = string.Empty;//當前文件的擴展名 fileName = Path.GetFileName(file.FileName); // string returnName = imgServerPath; bool result = false; string NewFileName = string.Empty; fileExtention = fileName.Substring(fileName.LastIndexOf(".")).ToLower(); NewFileName = PPQuery.event_id + newRand + fileExtention; string ServerPath = string.Empty; //判斷目錄是否存在,不存在則創建 //string[] mapPath = new string[1]; //mapPath[0] = promoPath.Substring(1, promoPath.Length - 2); //string s = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1); CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/')); // returnName += promoPath + NewFileName; fileName = NewFileName; NewFileName = localPromoPath + NewFileName;//絕對路徑 ServerPath = Server.MapPath(imgLocalServerPath + promoPath); string ErrorMsg = string.Empty; //上傳之前刪除已有的圖片 string oldFileName = olderpcmodel.banner_image; FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd); List<string> tem = ftp.GetFileList(); if (tem.Contains(oldFileName)) { FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd); ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片 DeletePicFile(ServerPath + oldFileName);//刪除本地圖片 } try { //上傳 result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd); if (result)//上傳成功 { PPQuery.banner_image = fileName; } } catch (Exception) { PPQuery.banner_image = olderpcmodel.banner_image; } } } catch (Exception) { PPQuery.banner_image = olderpcmodel.banner_image; } #endregion #region 注釋上傳圖片 ////string nowtime = DateTime.Now.ToString("hhmm"); //Random rand = new Random(); //int nowtime = rand.Next(1000, 9999); //try //{ // string saveFoler = Server.MapPath("~/aimg.gigade100.com/active/"); // string savePath, fileName, oldsavePath; // for (int iFile = 0; iFile < Request.Files.Count; iFile++) // { // HttpPostedFileBase postedFile = Request.Files[iFile]; // fileName = Path.GetFileName(postedFile.FileName); // if (fileName != "") // { // string fileType = fileName.Substring(fileName.LastIndexOf(".")); // string newName = GetEventId(oldermodel.event_type, model.id.ToString()) + nowtime + fileType; // oldsavePath = olderpcmodel.banner_image; // oldsavePath = saveFoler + oldsavePath; // savePath = saveFoler + newName; // if (System.IO.File.Exists(oldsavePath)) // {//检查是否在服务器上已经存在用户上传的同名文件 // System.IO.File.Delete(oldsavePath); // } // if (fileType.ToLower() == ".jpg" || fileType.ToLower() == ".png" || fileType.ToLower() == ".gif" || fileType.ToLower() == ".jpeg") // { // if (postedFile.ContentLength <= 300 * 1024) // { // postedFile.SaveAs(savePath); // PPQuery.banner_image = newName; // } // else // { // jsonStr = "{success:false,msg:1}"; // this.Response.Clear(); // this.Response.Write(jsonStr.ToString()); // this.Response.End(); // return this.Response; // } // } // else // { // jsonStr = "{success:false,msg:2}"; // this.Response.Clear(); // this.Response.Write(jsonStr.ToString()); // this.Response.End(); // return this.Response; // } // } // else // { // PPQuery.banner_image = olderpcmodel.banner_image; // } // } //} //catch (Exception) //{ // PPQuery.banner_image = olderpcmodel.banner_image; //} #endregion try//存連接地址 id是否也添加時間 { PPQuery.category_link_url = phpwebhost + "/pair/red_green_match.php?event_id=" + PPQuery.event_id; } catch (Exception) { PPQuery.category_link_url = oldPPQuery.category_link_url; } //foreach (string rid in Request.Params["rowid"].ToString().Split('|')) //{ // if (!string.IsNullOrEmpty(rid)) // { // query.id = Convert.ToInt32(rid); // _promopairMgr.Update(query); // } //} if (_promopairMgr.CategoryID(model).ToString() == "true") { _promopairMgr.Update(model, PPQuery); jsonStr = "{success:true}"; } else { jsonStr = "{success:false,msg:3}"; } } 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); jsonStr = "{success:false}"; } } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
public HttpResponseBase SaveOne() { string jsonStr = String.Empty; try { PromoPair model = new PromoPair(); _promopairMgr = new PromoPairMgr(mySqlConnectionString); model.event_type = "P1"; model.event_name = Request.Params["name"].ToString(); model.event_desc = Request.Params["desc"].ToString(); model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString(); model.created = DateTime.Now; model.muser = model.kuser; model.modified = model.created; model.id = _promopairMgr.Save(model); // _promopairMgr.Save(model); System.Data.DataTable dt = _promopairMgr.Select(model); //_promopairMgr.Select(query); if (dt.Rows.Count > 0) { jsonStr = "{success:true,id:" + dt.Rows[0]["id"] + ",cateID:" + dt.Rows[0]["category_id"] + ",cate_red:" + dt.Rows[0]["cate_red"] + ",cate_green:" + dt.Rows[0]["cate_green"] + "}"; } else { jsonStr = "{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); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
public int Delete(Parametersrc m) { int i = 0; MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); StringBuilder sb = new StringBuilder(); try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; PromoPair pp = new PromoPair(); if (m.Rowid != 0) { sb.AppendFormat("Delete from t_parametersrc where Rowid ='{0}';", m.Rowid); } mySqlCmd.CommandText = sb.ToString(); i += mySqlCmd.ExecuteNonQuery(); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromoPair-->Delete-->" + ex.Message +",sql:"+ sb.ToString(), ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return i; }
public DataTable Select(PromoPair Model) { try { return _PPairDao.Select(Model); } catch (Exception ex) { throw new Exception("PromoPairMgr-->Select-->" + ex.Message, ex); } }
public string CategoryID(PromoPair model) {//查詢紅和綠是否有選擇商品(促銷商品維護) model.Replace4MySQL(); StringBuilder sb = new StringBuilder(); DataTable dt, dt_red, dt_green; try { dt = _access.getDataTable(String.Format("select cate_red,cate_green from promo_pair where id={0} ", model.id)); if (dt.Rows.Count > 0) { dt_red = _access.getDataTable(String.Format("SELECT product_id FROM product_category_set WHERE category_id={0} ", dt.Rows[0][0].ToString())); if (dt_red.Rows.Count > 0) { dt_green = _access.getDataTable(String.Format("SELECT product_id FROM product_category_set WHERE category_id={0} ", dt.Rows[0][1].ToString())); if (dt_green.Rows.Count > 0) return "true"; else return "green"; } else return "red"; } else return "false"; } catch (Exception ex) { throw new Exception("PromoPairDao-->CategoryID-->" + ex.Message, ex); } }
public string CategoryID(PromoPair Model) { try { return _PPairDao.CategoryID(Model); } catch (Exception ex) { throw new Exception("PromoPairMgr-->CategoryID-->" + ex.Message, ex); } }
public DataTable SelCategoryID(PromoPair model) {//查詢出該id的category_id model.Replace4MySQL(); StringBuilder sb = new StringBuilder(); try { sb.AppendFormat("select category_id from promo_pair where 1=1", model.id); if (model.id != 0) { sb.AppendFormat(" and id='{0}' ;", model.id); } return _access.getDataTable(sb.ToString()); } catch (Exception ex) { throw new Exception("PromoPairDao-->SelCategoryID-->" + ex.Message + sb.ToString(), ex); } }
public DataTable Select(PromoPair model) {//查詢出選擇id的所有主表信息 model.Replace4MySQL(); StringBuilder sb = new StringBuilder(); try { sb.Append(@" select id , event_name , event_desc , event_type , condition_id , group_id , start as starts , end , created , modified , active , deliver_type , device , payment_code , cate_red , cate_green , kuser , muser , website, category_id , price , discount , status from promo_pair where 1=1"); if (model.id != 0) { sb.AppendFormat(" and id='{0}'", model.id); } return _access.getDataTable(sb.ToString()); } catch (Exception ex) { throw new Exception("PromoPairDao-->Select-->" + ex.Message + sb.ToString(), ex); } }
public int Delete(Model.PromoPair query) { int i = 0; MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); string sql = String.Empty; string sqlSW = ""; try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; PromoPair pp = new PromoPair(); if (query.id != 0) { pp = GetModelById(query.id); sqlSW += DeletePromoPair(pp.id); if (pp.category_id != 0) { sqlSW += _proCateDao.Delete(Convert.ToUInt32(pp.category_id)); sqlSW += _proCateDao.Delete(Convert.ToUInt32(pp.cate_red)); sqlSW += _proCateDao.Delete(Convert.ToUInt32(pp.cate_green)); //sqlSW += _prodCategSet.DelProdCateSet(Convert.ToUInt32(pp.cate_red)); //sqlSW += _prodCategSet.DelProdCateSet(Convert.ToUInt32(pp.cate_green)); } } mySqlCmd.CommandText = sqlSW.ToString(); sql = mySqlCmd.CommandText; i += mySqlCmd.ExecuteNonQuery(); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromoPair-->Delete-->" + ex.Message + sql, ex); } finally { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open) { mySqlConn.Close(); } } return i; }
public int Update(PromoPair model, PromoPairQuery PPquery) { int id = 0; StringBuilder sb = new StringBuilder(); MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) mySqlConn.Open(); mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; sb.AppendFormat(@"update promo_pair set condition_id='{1}',group_id='{2}',`start`='{3}',`end`='{4}',modified='{5}',deliver_type='{6}',device='{7}',muser='******',website='{9}',event_name='{10}',event_desc='{11}',price='{12}',discount='{13}',vendor_coverage='{14}',active=0 where id={0} ; ", model.id, model.condition_id, model.group_id, CommonFunction.DateTimeToString(model.starts), CommonFunction.DateTimeToString(model.end), CommonFunction.DateTimeToString(model.modified), model.deliver_type, model.device, model.muser, model.website, model.event_name, model.event_desc, model.price, model.discount,model.vendor_coverage); #region 操作修改ProductCategory ProductCategoryDao _categoryDao = new ProductCategoryDao(connStr); ProductCategory pcmodel = _categoryDao.GetModelById(Convert.ToUInt32(model.category_id)); pcmodel.category_id = Convert.ToUInt32(model.category_id); pcmodel.banner_image = PPquery.banner_image; pcmodel.category_link_url = PPquery.category_link_url; pcmodel.category_name = model.event_name; pcmodel.category_display = Convert.ToUInt32(model.status); sb.Append(_proCateDao.UpdateProdCate(pcmodel)); #endregion #region 刪除原來的商品信息再新增 mySqlCmd.CommandText = _prodPromoDao.DeleteProdProm(PPquery.event_id); mySqlCmd.ExecuteScalar(); ////查詢出商品信息后插入prod_promo表 //if (model.active) //{ // DataTable dt = _access.getDataTable("SELECT cate_red,cate_green FROM promo_pair WHERE id=" + model.id + ""); // DataTable dt_red = _access.getDataTable("SELECT product_id FROM product_category_set WHERE category_id=" + dt.Rows[0]["cate_red"] + " ;"); // DataTable dt_green = _access.getDataTable("SELECT product_id FROM product_category_set WHERE category_id=" + dt.Rows[0]["cate_green"] + " ;"); // if (dt_red.Rows.Count > 0) // { // for (int i = 0; i < dt_red.Rows.Count; i++) // { // ProdPromo ppmodel = new ProdPromo(); // ppmodel.product_id = Convert.ToInt32(dt_red.Rows[i][0].ToString()); // ppmodel.event_id = PPquery.event_id; // ppmodel.event_type = model.event_type; // ppmodel.event_desc = model.event_desc; // ppmodel.start = model.starts; // ppmodel.end = model.end; // ppmodel.page_url = PPquery.category_link_url; // if (model.group_id == 0 && model.condition_id == 0) // ppmodel.user_specified = 0; // else // ppmodel.user_specified = 1; // ppmodel.kuser = model.muser; // ppmodel.kdate = model.modified; // ppmodel.muser = model.muser; // ppmodel.mdate = model.modified; // ppmodel.status = model.status; // sb.Append(_prodPromoDao.SaveProdProm(ppmodel)); // } // } // if (dt_green.Rows.Count > 0) // { // for (int i = 0; i < dt_green.Rows.Count; i++) // { // ProdPromo ppmodel = new ProdPromo(); // ppmodel.product_id = Convert.ToInt32(dt_green.Rows[i][0].ToString()); // ppmodel.event_id = PPquery.event_id; // ppmodel.event_type = model.event_type; // ppmodel.event_desc = model.event_desc; // ppmodel.start = model.starts; // ppmodel.end = model.end; // ppmodel.page_url = PPquery.category_link_url; // if (model.group_id == 0 && model.condition_id == 0) // ppmodel.user_specified = 0; // else // ppmodel.user_specified = 1; // ppmodel.kuser = model.muser; // ppmodel.kdate = model.modified; // ppmodel.muser = model.muser; // ppmodel.mdate = model.modified; // ppmodel.status = model.status; // sb.Append(_prodPromoDao.SaveProdProm(ppmodel)); // } // } //} #endregion //if (PPquery.event_id != "") //{ // sb.Append(_promoAllDao.DelPromAll(PPquery.event_id)); //} mySqlCmd.CommandText = sb.ToString(); id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromoPairDao-->Update-->" + ex.Message, ex); } finally { mySqlConn.Close(); } return id; }
public int SaveOne(PromoPair model) { int id = 0; MySqlCommand mySqlCmd = new MySqlCommand(); MySqlConnection mySqlConn = new MySqlConnection(connStr); try { if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed) { mySqlConn.Open(); } mySqlCmd.Connection = mySqlConn; mySqlCmd.Transaction = mySqlConn.BeginTransaction(); mySqlCmd.CommandType = System.Data.CommandType.Text; StringBuilder sb = new StringBuilder(); string father_id = _access.getDataTable("SELECT parameterProperty from t_parametersrc where parameterCode='P1';").Rows[0][0].ToString(); ProductCategory pmodel = new ProductCategory(); pmodel.category_father_id = Convert.ToUInt32(father_id); pmodel.category_name = model.event_name; pmodel.category_display = 1; pmodel.category_show_mode = 0; pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime(); pmodel.category_display = 0; mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel); //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate) values('{0}','{1}','{2}','{3}','{4}'); select @@identity ;", father_id, model.event_name, "1", "0", CommonFunction.GetPHPTime(model.created.ToString())); model.category_id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); //修改表serial Serial serial = new Serial(); serial.Serial_id = 12; serial.Serial_Value = Convert.ToUInt32(model.category_id); mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serial); id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); #region insert red+green pmodel.category_father_id = Convert.ToUInt32(model.category_id); pmodel.category_name = "紅"; mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel); model.cate_red = Convert.ToInt32(mySqlCmd.ExecuteScalar()); //修改表serial Serial serialred = new Serial(); serialred.Serial_id = 12; serialred.Serial_Value = Convert.ToUInt32(model.cate_red); mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialred); id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "紅", "1", "0", CommonFunction.GetPHPTime(model.created.ToString())); pmodel.category_name = "綠"; mySqlCmd.CommandText = _proCateDao.SaveCategory(pmodel); model.cate_green = Convert.ToInt32(mySqlCmd.ExecuteScalar()); //修改表serial Serial serialgreen = new Serial(); serialgreen.Serial_id = 12; serialgreen.Serial_Value = Convert.ToUInt32(model.cate_green); mySqlCmd.CommandText = _serialDao.UpdateAutoIncreament(serialgreen); id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); //mySqlCmd.CommandText = string.Format("INSERT INTO product_category(category_father_id,category_name,category_display,category_show_mode,category_createdate,status) values('{0}','{1}','{2}','{3}','{4}',1); select @@identity ;", model.category_id, "綠", "1", "0", CommonFunction.GetPHPTime(model.created.ToString())); #endregion sb.AppendFormat("INSERT INTO promo_pair(event_name,event_desc,event_type,created,kuser,category_id,active,cate_red,cate_green,vendor_coverage) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'); select @@identity ;", model.event_name, model.event_desc, model.event_type, CommonFunction.DateTimeToString(model.created), model.kuser, model.category_id, "0", model.cate_red, model.cate_green,model.vendor_coverage); mySqlCmd.CommandText = sb.ToString(); id = Convert.ToInt32(mySqlCmd.ExecuteScalar()); mySqlCmd.Transaction.Commit(); } catch (Exception ex) { mySqlCmd.Transaction.Rollback(); throw new Exception("PromoPairDao-->SaveOne-->" + ex.Message, ex); } finally { mySqlConn.Close(); } return id; }