从listview子项中删除小数

时间:2017-01-20 12:22:32

标签: c# listview formatting format

我的listview正在填充sql查询。关于sql的数据是一个整数“25,4,9”等。但是当它添加到listview时它的“25.000,4.000”等我尝试使用(“0.#”)格式,但它只是告诉我它不能转换为整数。我遇到问题的子项目是[VOID_LENGTH]

            foreach (Dictionary<string, string> d in resultHistory)
            {
                ListViewItem lvi = new ListViewItem(d["LOT_NO"]);
                lvi.SubItems.Add(d["SERIAL_NO"]);
                lvi.SubItems.Add(d["DATE_TIME"]);
                lvi.SubItems.Add(d["VOID_LOC"]);
                lvi.SubItems.Add(d["VOID_LENGTH"]);
                lvi.SubItems.Add(d["EMPL_ID"]);

                listView1.Items.Add(lvi);
            }

查询

public List<Dictionary<string, string>> GetVoid(string VoidDate, bool orderByDate = false)
    {
        List<Dictionary<string, string>> results = new List<Dictionary<string, string>>();
        string query = "";
        List<OleDbParameter> queryParameters = new List<OleDbParameter>();

        query = "SELECT LOT_NO, SERIAL_NO, DATE_TIME, VOID_LOC, VOID_LENGTH, EMPL_ID ";
        query += "FROM MPCS.BRAZE_VOIDS ";
        query += "WHERE TRUNC(DATE_TIME) = TO_DATE(?, 'dd-MON-yy')";

        if (orderByDate)
        {
            query += " order by INS_UPD_TIMESTAMP asc, VOID_LOC desc";
        }

        queryParameters.Add(new OleDbParameter("DATE_TIME", VoidDate));

        results = this.ExecuteParameterQuery(query, queryParameters);
        return (results);
    }

1 个答案:

答案 0 :(得分:1)

您在DB中的列类型是十进制(n,3)我认为,您可以在选择时将其转换为int。像这样修改选择查询部分

cast(VOID_LENGTH as int) as VOID_LENGTH