예제 #1
0
파일: RateSet.cs 프로젝트: giagiigi/MYDZ
        /// <summary>
        ///
        /// </summary>
        /// <param name="tTradeRate"></param>
        /// <returns></returns>
        public bool AddRate(Tb_TradeRate tTradeRate)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TradeRate(");
            strSql.Append("ShopId,Result,Role,Content,SortID");
            strSql.Append(") values (");
            strSql.Append("@ShopId,@Result,@Role,@Content,@SortID");
            strSql.Append(") ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ShopId",  SqlDbType.Int,       4),
                new SqlParameter("@Result",  SqlDbType.VarChar,  50),
                new SqlParameter("@Role",    SqlDbType.VarChar,  50),
                new SqlParameter("@Content", SqlDbType.VarChar, 500),
                new SqlParameter("@SortID",  SqlDbType.Int, 4)
            };

            parameters[0].Value = tTradeRate.ShopId;
            parameters[1].Value = tTradeRate.Result;
            parameters[2].Value = tTradeRate.Role;
            parameters[3].Value = tTradeRate.Content;
            parameters[4].Value = tTradeRate.SortID;
            if (DBHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
파일: RateSet.cs 프로젝트: giagiigi/MYDZ
        /// <summary>
        ///
        /// </summary>
        /// <param name="shopId"></param>
        /// <returns></returns>
        public List <Tb_TradeRate> GetTradeRateByShopId(int shopId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, ShopId, Result, Role, Content, SortID  ");
            strSql.Append("  from TradeRate ");
            strSql.Append(" where ShopId=@ShopId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ShopId", SqlDbType.Int, 4)
            };
            parameters[0].Value = shopId;
            List <Tb_TradeRate> listrate   = new List <Tb_TradeRate>();
            IDataReader         DataReader = DBHelper.ExecuteReader(CommandType.Text, strSql.ToString(), parameters);

            while (DataReader.Read())
            {
                Tb_TradeRate rate = new Tb_TradeRate();
                rate.Id      = DataReader["Id"] == null ? 0 : Convert.ToInt32(DataReader["Id"]);
                rate.ShopId  = DataReader["ShopId"] == null ? 0 : Convert.ToInt32(DataReader["ShopId"]);
                rate.Result  = DataReader["Result"] == null ? "good" : Convert.ToString(DataReader["Result"]);
                rate.Role    = DataReader["Role"] == null ? "seller" : Convert.ToString(DataReader["Role"]);
                rate.Content = DataReader["Content"] == null ? "" : Convert.ToString(DataReader["Content"]);
                rate.SortID  = DataReader["SortID"] == null ? 1 : Convert.ToInt32(DataReader["SortID"]);
                listrate.Add(rate);
            }
            return(listrate);
        }
예제 #3
0
        public JsonResult SaveRateTmple(string result, string content, int sortid = 0)
        {
            bool         res        = false;
            tbClientUser clientuser = GetUser("UserInfo");
            Tb_TradeRate ttr        = new Tb_TradeRate();

            ttr.Content = content;
            ttr.Result  = result;
            ttr.Role    = "seller";
            ttr.ShopId  = clientuser.UserShops[0].Shop.ShopId;
            List <Tb_TradeRate> listtt = new List <Tb_TradeRate>();

            listtt = br.GetTradeRateByShopId(clientuser.UserShops[0].Shop.ShopId);
            if (listtt.Count > 0)
            {
                listtt.Sort((left, right) =>
                {
                    if (left.SortID > right.SortID)
                    {
                        return(-1);
                    }
                    else if (left.SortID == right.SortID)
                    {
                        return(0);
                    }
                    else
                    {
                        return(1);
                    }
                });
                ttr.SortID = listtt[0].SortID + 1;
            }
            else
            {
                ttr.SortID = 1;
            }
            if (br.AddRate(ttr))
            {
                res = true;
            }
            return(Json(new { Result = res }));
        }
예제 #4
0
파일: RateSet.cs 프로젝트: giagiigi/MYDZ
        /// <summary>
        ///
        /// </summary>
        /// <param name="RateId"></param>
        /// <returns></returns>
        public Tb_TradeRate GetTradeRateByRateId(int sortId, int shopid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, ShopId, Result, Role, Content, SortID  ");
            strSql.Append("  from TradeRate ");
            strSql.Append(" where sortId=@sortId");
            strSql.Append(" and ShopId=@ShopId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",     SqlDbType.Int, 4),
                new SqlParameter("@ShopId", SqlDbType.Int, 4)
            };
            parameters[0].Value = sortId;
            parameters[1].Value = shopid;

            Tb_TradeRate model = new Tb_TradeRate();
            DataSet      ds    = DBHelper.ExecuteDataSet(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ShopId"].ToString() != "")
                {
                    model.ShopId = int.Parse(ds.Tables[0].Rows[0]["ShopId"].ToString());
                }
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["SortID"].ToString() != "")
                {
                    model.SortID = int.Parse(ds.Tables[0].Rows[0]["SortID"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
파일: RateSet.cs 프로젝트: giagiigi/MYDZ
        /// <summary>
        ///
        /// </summary>
        /// <param name="tTradeRate"></param>
        /// <returns></returns>
        public bool UpdateRate(Tb_TradeRate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TradeRate set ");

            strSql.Append(" Result = @Result , ");
            strSql.Append(" Role = @Role , ");
            strSql.Append(" Content = @Content , ");
            strSql.Append(" SortID = @SortID  ");
            strSql.Append(" where Id=@Id ");
            strSql.Append(" and ShopId = @ShopId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",      SqlDbType.Int,       4),
                new SqlParameter("@ShopId",  SqlDbType.Int,       4),
                new SqlParameter("@Result",  SqlDbType.VarChar,  50),
                new SqlParameter("@Role",    SqlDbType.VarChar,  50),
                new SqlParameter("@Content", SqlDbType.VarChar, 500),
                new SqlParameter("@SortID",  SqlDbType.Int, 4)
            };

            parameters[5].Value  = model.Id;
            parameters[6].Value  = model.ShopId;
            parameters[7].Value  = model.Result;
            parameters[8].Value  = model.Role;
            parameters[9].Value  = model.Content;
            parameters[10].Value = model.SortID;
            int rows = DBHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        public Task <JsonResult> batchUpdateRate(string OidList, int sortid, bool IsSystemDefault = false)
        {
            tbClientUser clientuser = GetUser("UserInfo");

            return(Task.Factory.StartNew(() =>
            {
                if (string.IsNullOrEmpty(OidList))
                {
                    try
                    {
                        Tb_TradeRate ttr = new Tb_TradeRate();
                        if (IsSystemDefault)
                        {
                            ttr = br.GetTradeRateBySortId(sortid, clientuser.UserShops[0].Shop.ShopId);
                        }
                        else
                        {
                            ttr = br.GetTradeRateBySortId(sortid, -1);
                        }
                        string[] oiditems = OidList.Split(',');
                        traderateAddQueryCls traderatestr = new traderateAddQueryCls();
                        traderatestr.Content = ttr.Content;
                        traderatestr.Result = ttr.Result;
                        foreach (string item in oiditems)
                        {
                            traderatestr.Oid = Convert.ToInt64(item);
                            iit.AddTradeRate(clientuser.UserShops[0].SessionKey, traderatestr);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }).ContinueWith <JsonResult>(task =>
            {
                return Json(new { Result = true });
            }));
        }
예제 #7
0
 /// <summary>
 /// 更新评价内容
 /// </summary>
 /// <param name="tTradeRate"></param>
 /// <returns></returns>
 public bool UpdateRate(Tb_TradeRate tTradeRate)
 {
     return(SetTradeRate.UpdateRate(tTradeRate));
 }
예제 #8
0
 /// <summary>
 /// 添加一条评价内容
 /// </summary>
 /// <param name="TTradeRate"></param>
 /// <returns></returns>
 public bool AddRate(Tb_TradeRate tTradeRate)
 {
     return(SetTradeRate.AddRate(tTradeRate));
 }