public HttpResponseBase ProductDown() { string json = "{success:true}"; _prodVdReq = new ProdVdReqMgr(connectionString); _productMgr = new ProductMgr(connectionString); try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor; uint product_end = 0; string dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(DateTime.Now.ToString())); var explain = Request.Form["explain"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["Product_End"])) { dtime = CommonFunction.DateTimeToString(Convert.ToDateTime(Request.Form["Product_End"].ToString())); product_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Form["Product_End"])); } foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (product_end == 0)//說明是立即下架,就用原來的時間 { product_end = pro.Product_End; } if (pro != null && pro.Product_Status == 5)// && pro.user_id == (Session["caller"] as Caller).user_id { ProdVdReqQuery prodQuery = new ProdVdReqQuery(); prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodQuery.product_id = Convert.ToInt32(product_id); prodQuery.req_status = 1; int totalCount = 0; ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault(); if (prodRquery == null) { prodRquery = new ProdVdReq(); prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = Convert.ToDateTime(dtime); prodRquery.req_type = 2; prodRquery.explain = explain + dtime; if (_prodVdReq.Insert(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } else { prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = Convert.ToDateTime(dtime); prodRquery.req_type = 2; prodRquery.explain = explain + dtime; if (_prodVdReq.Update(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } } } } } //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 ProductUp() { string json = "{success:true}"; BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor; _prodVdReq = new ProdVdReqMgr(connectionString); _productMgr = new ProductMgr(connectionString); try { if (!string.IsNullOrEmpty(Request.Form["Product_Id"])) { string[] pro_Ids = Request.Form["Product_Id"].Split('|'); foreach (string str in pro_Ids.Distinct()) { if (!string.IsNullOrEmpty(str)) { uint product_id = uint.Parse(str); Product pro = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (pro != null && pro.Product_Status != 5) { ProdVdReqQuery prodQuery = new ProdVdReqQuery(); prodQuery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodQuery.product_id = Convert.ToInt32(product_id); prodQuery.req_status = 1; int totalCount = 0; ProdVdReq prodRquery = _prodVdReq.QueryProdVdReqList(prodQuery, out totalCount).FirstOrDefault(); if (prodRquery == null) { prodRquery = new ProdVdReq(); prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = DateTime.Now; prodRquery.req_type = 1; if (_prodVdReq.Insert(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } else { prodRquery.vendor_id = Convert.ToInt32(vendor.vendor_id); prodRquery.product_id = Convert.ToInt32(product_id); prodRquery.req_status = 1; prodRquery.req_datatime = DateTime.Now; prodRquery.req_type = 1; if (_prodVdReq.Update(prodRquery) < 0) { json = "{success:false,msg:0}";//返回json數據 } } } } } } //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; }