Exemple #1
0
        public HttpResponseMessage queryCredit_date([FromBody] CREDIT_QUERY c)
        {
            Result <CREDIT> ru        = new Result <CREDIT>();
            List <CREDIT>   lcustomer = new List <CREDIT>();

            try
            {
                lcustomer = DB_Credit.getCredit_query(c);

                if (lcustomer.Count > 0)
                {
                    ru.code    = "7040";
                    ru.success = "true";
                    ru.message = "获取成功!";
                }
                else
                {
                    ru.code    = "7041";
                    ru.success = "false";
                    ru.message = "无数据";
                }
            }
            catch (Exception e)
            {
                ru.code    = "7042";
                ru.success = "false";
                ru.message = e.Message;
            }

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

            return(Conn.toJson(ru));
        }
 /// <summary>
 /// 查询
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public static List <CREDIT> getCredit_query(CREDIT_QUERY c)
 {
     using (SqlConnection conn = new SqlConnection(Conn.connString))
     {
         conn.Open();
         string sql = "";
         if (c.type == "date")
         {
             sql = string.Format("select * from T_CREDIT where UID='{0}' AND DATE='{1}' ", c.uid, c.date);
         }
         else
         {
             sql = string.Format("select A.* from T_CREDIT A LEFT JOIN T_CUSTOMER B ON A.CID=B.ID where A.UID='{0}' AND B.NAME='{1}' ", c.uid, c.uname);
         }
         DataTable      dt = new DataTable();
         SqlDataAdapter da = new SqlDataAdapter(sql, conn);
         da.Fill(dt);
         return(DataToCredit(dt));
     }
 }