예제 #1
0
 public int Insert(ProdVdReq query)
 {
     try
     {
         return _prodVbReqdao.Insert(query);
     }
     catch (Exception ex)
     {
         throw new Exception("ProdVdReqMgr.Insert-->" + ex.Message, ex);
     }
 }
예제 #2
0
 public int Update(ProdVdReq query)
 {
     try
     {
         return _prodVbReqdao.Update(query);
     }
     catch (Exception ex)
     {
         throw new Exception("ProdVdReqMgr.Update-->" + ex.Message, ex);
     }
 }
        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;
        }
예제 #5
0
 public int Insert(ProdVdReq query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         query.Replace4MySQL();
         sql.Append(" Insert into prod_vd_req  (  ");
         sql.Append(" vendor_id,product_id,req_status,req_datatime,`explain`,");
         sql.Append("req_type,user_id,reply_datetime,reply_note ) values ( ");
         sql.AppendFormat("'{0}','{1}','{2}','{3}','{4}',",
             query.vendor_id, query.product_id, query.req_status, CommonFunction.DateTimeToString(query.req_datatime), query.explain);
         sql.AppendFormat("'{0}','{1}','{2}','{3}' );",
            query.req_type, query.user_id, CommonFunction.DateTimeToString(query.reply_datetime), query.reply_note);
         return _dbAccess.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ProdVdReqDao.Insert-->" + ex.Message + sql.ToString(), ex);
     }
 }
예제 #6
0
        public int Update(ProdVdReq query)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                query.Replace4MySQL();
                sql.Append("set sql_safe_updates=0;");
                sql.Append(" update prod_vd_req   set  ");
                sql.AppendFormat(" vendor_id='{0}'", query.vendor_id);
                sql.AppendFormat(" ,req_status='{0}' ", query.req_status);
                sql.AppendFormat(" ,req_datatime='{0} ' ", CommonFunction.DateTimeToString(query.req_datatime));
                sql.AppendFormat(" ,`explain`='{0}' ", query.explain);
                sql.AppendFormat(" ,req_type='{0}' ", query.req_type);
                sql.AppendFormat(" ,reply_note='{0}' ", query.reply_note);
                sql.AppendFormat(" ,reply_datetime='{0}' ", CommonFunction.DateTimeToString(query.reply_datetime));
                sql.AppendFormat(" ,user_id='{0}' ", query.user_id);
                sql.AppendFormat(" where product_id= '{0}'", query.product_id);
                sql.AppendFormat(" and rid= '{0}'", query.rid);

                sql.Append(";set sql_safe_updates=1;");
                return _dbAccess.execCommand(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ProdVdReqDao.Update-->" + ex.Message + sql.ToString(), ex);
            }
        }