示例#1
0
        public HttpResponseMessage queryProduct_date([FromBody] PRODUCT_DATE_PARAMETER p)
        {
            Result <PRODUCT_DATE_R> ru       = new Result <PRODUCT_DATE_R>();
            List <PRODUCT_DATE_R>   lproduct = new List <PRODUCT_DATE_R>();

            try
            {
                lproduct = DB_Product.getProduct(p);

                if (lproduct.Count > 0)
                {
                    ru.code    = "3030";
                    ru.success = "true";
                    ru.message = "获取成功!";
                }
                else
                {
                    ru.code    = "3031";
                    ru.success = "false";
                    ru.message = "无数据";
                }
            }
            catch (Exception e)
            {
                ru.code    = "3032";
                ru.success = "false";
                ru.message = e.Message;
            }

            ru.systemTime = Conn.GetTimeStamp();
            ru.data       = lproduct;

            return(Conn.toJson(ru));
        }
示例#2
0
        /// <summary>
        /// 根据日期查询
        /// </summary>
        /// <param name="date"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <PRODUCT_DATE_R> getProduct(PRODUCT_DATE_PARAMETER p)
        {
            using (SqlConnection conn = new SqlConnection(Conn.connString))
            {
                conn.Open();
                string sqlwhere;
                if (p.type == "month")
                {
                    sqlwhere = string.Format(@" SUBSTRING(A.DATE,1,7) = '{0}'", p.date);
                }
                else
                {
                    sqlwhere = string.Format(@" SUBSTRING(A.DATE,1,4) = '{0}'", p.date);
                }
                sqlwhere += string.Format(@" AND A.UID='{0}'", p.uid);

                string         sql = string.Format("select B.UID,B.NAME,B.PRICE,SUM(COUNT) AS NUM from T_CREDIT A LEFT JOIN T_PRODUCT B ON A.PID=B.ID WHERE {0} GROUP BY B.UID,B.NAME,B.PRICE ", sqlwhere);
                DataTable      dt  = new DataTable();
                SqlDataAdapter da  = new SqlDataAdapter(sql, conn);
                da.Fill(dt);
                return(DataToProductR(dt));
            }
        }