Last Updated: February 25, 2016
·
371
· vitochung

CopyRow

When we use CopyRow() to insert data with SQL language instead of datatable,
be careful to fill field data into DATE field
Within DBMinDate will show as

資料回存錯誤:
並行違規:UpdateCommand已經影響必須是1記錄的0

private void SetKeyFunc(DataRow[] drs)
{
    DateTime NextDate; ProcessType NexttTp;
    DateTime excDate; ProcessType proctp;
    CommonUtility.PfoInfo.GetStatus(CommonFuncs.ConvertEditValue<int>(leContractno),
        out NextDate, out NexttTp, out excDate, out proctp);

    DateTime tradr_date = excDate;

    string tmpNo = CommonFuncs.GetNextNo("td_deal_buy", "TDB", excDate, "tradeno", 15);
    string leadingCode = tmpNo.Substring(0, 11);
    int index = int.Parse(tmpNo.Substring(11, 4));

    for (int i = 0; i < drs.GetLength(0); i++)
    {
        drs[i].FieldbyName("trade_date").asDateTime = excDate;
        drs[i].FieldbyName("tradeno").asString = leadingCode + string.Format("{0:0000}", index + i);
        drs[i].FieldbyName("td_no").asString = string.Empty;
        drs[i].FieldbyName("inv_status").asBoolean = false;
        drs[i].FieldbyName("book").asBoolean = false;
        drs[i].FieldbyName("invtime").asDateTime = excDate;
    }
    //copyFlag = true;
}