Пример #1
0
 /// <summary>
 /// 新增promotionsamountfare的sql語句,用於事物的調用
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string SavePromoFare(PromotionsAmountFare model)
 {
     model.Replace4MySQL();
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat("insert into  promotions_amount_fare (");
         sql.AppendFormat("name,display,delivery_store,group_id,class_id,brand_id,category_id,product_id,type,amount,quantity,start,end,");
         sql.AppendFormat("created,active,event_desc,event_type,condition_id,device,kuser,fare_percent,payment_code,off_times,url_by,site,modified,muser,status,vendor_coverage) values ");
         sql.AppendFormat("('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}',{14},'{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}');select @@identity;",
          model.name, model.display, model.delivery_store, model.group_id, model.class_id, model.brand_id,
          model.category_id, model.product_id, model.type, model.amount, model.quantity, CommonFunction.DateTimeToString(model.start),
          CommonFunction.DateTimeToString(model.end),
          CommonFunction.DateTimeToString(model.created),
          model.active ? 1 : 0, model.event_desc, model.event_type,
          model.condition_id, model.device, model.kuser,
          model.fare_percent, model.payment_code, model.off_times,
          model.url_by, model.site, CommonFunction.DateTimeToString(model.modified), model.muser, model.status, model.vendor_coverage);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("PromotionsAmountFareDao-->SavePromoFare-->" + ex.Message, ex);
     }
 }
Пример #2
0
 /// <summary>
 /// 根據編號獲取數據
 /// </summary>
 /// <param name="model">滿額滿件免運對象</param>
 /// <returns>數據列表</returns>
 public DataTable Select(PromotionsAmountFare model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     sb.Append(@" select id, name,display,delivery_store,group_id,class_id,brand_id,category_id,product_id,type,amount,quantity,start,end,
    created,active,event_desc,event_type,condition_id,device,kuser,fare_percent,payment_code,off_times,url_by,
     site,modified,muser,status,vendor_coverage from promotions_amount_fare where 1=1");
     if (model.id != 0)
     {
         sb.AppendFormat(" and id='{0}';", model.id);
     }
     try
     {
         return _access.getDataTable(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("PromotionsAmountFareDao-->Select-->" + ex.Message + sb.ToString(), ex);
     }
 }
Пример #3
0
 /// <summary>
 /// 頁面的第一次保存,向product_category和promotionsAmountFare中新增基本數據并分別獲取category_id和id
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Save(PromotionsAmountFareQuery model)
 {
     model.Replace4MySQL();
     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;
         //#region 保存第一步到product_category 獲取prodduct_amount_fare的category_id
         ProductCategory pmodel = new ProductCategory();
         pmodel.category_name = model.name;
         pmodel.category_createdate = (uint)BLL.gigade.Common.CommonFunction.GetPHPTime();
         pmodel.category_father_id = model.category_father_id;
         pmodel.category_ipfrom = model.category_ipfrom;
         pmodel.category_display = Convert.ToUInt32(model.status);
         mySqlCmd.CommandText = _cateDao.SaveCategory(pmodel);
         model.category_id = Convert.ToUInt32(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());
         //#endregion
         PromotionsAmountFare pfmodel = new PromotionsAmountFare();
         pfmodel.name = model.name;
         pfmodel.event_desc = model.event_desc;
         pfmodel.vendor_coverage = model.vendor_coverage;
         pfmodel.event_type = model.event_type;
         pfmodel.kuser = model.kuser;
         pfmodel.created = model.created;
         pfmodel.active = model.active;
         pfmodel.category_id = model.category_id;
         pfmodel.status = model.status;
         pfmodel.payment_code = model.payment_code;
         mySqlCmd.CommandText = SavePromoFare(pfmodel);
         id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("PromotionsAmountFareDao-->Save-->" + ex.Message, ex);
     }
     finally
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
         {
             mySqlConn.Close();
         }
     }
     return id;
 }
        public HttpResponseBase FirstSaveFare()
        {
            string jsonStr = String.Empty;
            try
            {
                PromotionsAmountFareQuery model = new PromotionsAmountFareQuery();
                if (!string.IsNullOrEmpty(Request.Params["name"].ToString()))
                {
                    model.name = Request.Params["name"].ToString();
                }
                else
                {
                    model.name = string.Empty;
                }
                if (!string.IsNullOrEmpty(Request.Params["desc"].ToString()))
                {
                    model.event_desc = Request.Params["desc"].ToString();
                }
                else
                {
                    model.event_desc = string.Empty;
                }
                if (!string.IsNullOrEmpty(Request.Params["vendor_coverage"]))
                {
                    model.vendor_coverage = Convert.ToInt32(Request.Params["vendor_coverage"].ToString());
                }
                else
                {
                    model.vendor_coverage = 0;
                }

                if (!string.IsNullOrEmpty(Request.Params["amount"].ToString()))
                {
                    model.amount = Convert.ToInt32(Request.Params["amount"].ToString());
                }
                else
                {
                    model.amount = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["quantity"].ToString()))
                {
                    model.quantity = Convert.ToInt32(Request.Params["quantity"].ToString());
                }
                else
                {
                    model.quantity = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["fare_percent"].ToString()))
                {
                    model.fare_percent = Convert.ToInt32(Request.Params["fare_percent"].ToString());
                }
                else
                {
                    model.fare_percent = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["off_times"].ToString()))
                {
                    model.off_times = Convert.ToInt32(Request.Params["off_times"].ToString());
                }
                else
                {
                    model.off_times = 0;
                }




                model.kuser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString();
                model.created = DateTime.Now;
                model.status = 0;

                //獲取event_type和category_father_id
                _parasrcMgr = new ParameterMgr(mySqlConnectionString);
                List<Parametersrc> fatherIdResult = _parasrcMgr.QueryUsed(new Parametersrc { ParameterType = "event_type", parameterName = Request.Params["event_type"].ToString(), Used = 1 });
                if (fatherIdResult.Count == 1)
                {
                    model.event_type = fatherIdResult[0].ParameterCode;
                    model.category_father_id = Convert.ToUInt32(fatherIdResult[0].ParameterProperty);
                }

                model.category_ipfrom = Request.UserHostAddress;//獲取當前ip

                _promoAmountFareMgr = new PromotionsAmountFareMgr(mySqlConnectionString);
                PromotionsAmountFare query = new PromotionsAmountFare();
                query.id = _promoAmountFareMgr.Save(model);
                System.Data.DataTable dt = _promoAmountFareMgr.Select(query);

                if (dt.Rows.Count > 0)
                {
                    jsonStr = "{success:true,\"id\":\"" + dt.Rows[0]["id"] + "\",\"cateID\":\"" + dt.Rows[0]["category_id"] + "\",\"event_type\":\"" + dt.Rows[0]["event_type"] + "\"}";
                }
                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;
        }