在c#

时间:2016-06-10 22:27:07

标签: c# date format report

我开发了一个使用报告的应用程序,当我尝试打印报告时,我的问题是日期格式在客户端PC上更改为另一种格式,虽然它在我的电脑上以正确的格式打印日期,这里有两张图片第一个来自我的电脑,另一个来自客户端电脑

我的电脑

enter image description here

客户端电脑 enter image description here

这是我用来显示报告的代码

string DateString = dateTimePicker1.Value.ToString("yyyy/MM/dd");
        DateTime dt = DateTime.ParseExact(DateString, "yyyy/MM/dd", null);
        string DateString2 = dateTimePicker2.Value.ToString("yyyy/MM/dd");
        DateTime dt2 = DateTime.ParseExact(DateString2, "yyyy/MM/dd", null);

        dailyworkTableAdapter.Fill(this.workingmgmtDataSet1.dailywork,label2.Text,dt,dt2);
        dataTable1TableAdapter.Fill(this.finalDS.DataTable1,dt,dt2,label2.Text);

        this.reportViewer1.RefreshReport();

报告中的日期字段表达:

=Fields!date.Value

2 个答案:

答案 0 :(得分:3)

客户端电脑似乎是针对不同的文化设置的。您可以强制使用日期时间值的格式:

#pragma pack(push, 1)
struct Header
{
    uint16_t marker;
    uint8_t msg_type;
    uint64_t sequence_id;
    uint64_t timestamp;
    uint8_t msg_direction;
    uint16_t msg_len;
};
#pragma pack(pop)
struct OrderEntryMessage
{
    Header header;
    uint64_t price;
    uint32_t qty;
    char instrument[10];
    uint8_t side;
    uint64_t client_assigned_id;
    uint8_t time_in_force;
    char trader_tag[3];
    uint8_t firm_id;
    char firm[256] ; 
    char termination_string[8]; 
};

struct AcknowledgementMessage
{
    Header header;
    uint32_t order_id;
    uint64_t client_id;
    uint8_t order_status;
    uint8_t reject_code;
    char termination_string[8];
};

struct OrderFillMessage
{
    Header header;
    uint32_t order_id;
    uint64_t fill_price;
    uint32_t fill_qty;
    uint8_t no_of_contras;
    uint8_t firm_id;
    char trader_tag[3];
    uint32_t qty;
    char termination_string[8]; 
};
void TradeDecoder::createMessage()
{
    ifstream file("example_data_file.bin", std::ios::binary);

     //I want to somehow Loop here to keep looking for headers ST

    Header h;
    file.read ((char*)&h.marker, sizeof(h.marker));
    file.read ((char*)&h.msg_type, sizeof(h.msg_type));
    file.read ((char*)&h.sequence_id, sizeof(h.sequence_id));
    file.read ((char*)&h.timestamp, sizeof(h.timestamp));
    file.read ((char*)&h.msg_direction, sizeof(h.msg_direction));
    file.read ((char*)&h.msg_len, sizeof(h.msg_len));
    file.close();

    switch(h.sequence_id)
    {
        case 1: 
            createOrderEntryMessage(h); //this methods creates a OrderEntryMessage with the header
        break;
        case 2:
            createOrderAckMessage(h); //same as above
        break;
        case 3:
            createOrderFillMessage(h); //same as above
        break;
        default:
        break;
    }
}  

您可以查看文化命名空间,了解有关处理此类事情的更多信息:https://msdn.microsoft.com/en-us/library/5hh873ya(v=vs.90).aspx

答案 1 :(得分:1)

解决了,问题是由于报告语言,在将语言设置为“阿拉伯语”后,问题解决了。

感谢。