Ejemplo n.º 1
0
    //加入符合此品號/期別的贈品資料
    public static string Add_Gift(string sItem, string sPeriod, string sPageTimeStamp)
    {
        String rtnValue = "";

        if (sItem != "" && sPeriod != "")
        {
            PUR_PUR022 PUR022 = new PUR_PUR022();
            DataTable dtGift = (DataTable)PUR022.Session["PUR02_Gift_" + sPageTimeStamp];
            DataTable dtDetail = (DataTable)PUR022.Session["PUR02_DTL_" + sPageTimeStamp];

            if (dtGift == null)
            {
                MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);
                dtGift = bco.QueryGiftSchema();
            }

            MaintainGift Gbco = new MaintainGift(ConntionDB);
            ParameterList.Clear();
            ParameterList.Add(sItem);
            ParameterList.Add(sPeriod);
            ParameterList.Add(-1);
            DataTable dtTmp = Gbco.QueryGift(ParameterList);
            int iAddRow = 0;
            if (dtTmp != null && dtTmp.Rows.Count > 0)
            {
                for (int i = 0; i < dtTmp.Rows.Count; i++)
                {
                    if (dtTmp.Rows[i]["ID"].ToString() != "0")
                    {
                        DataRow dr = dtGift.NewRow();
                        dr["ID"] = 1 + i;
                        dr["ITEM"] = sItem;
                        dr["PERIOD"] = sPeriod;
                        dr["VIRTUAL_CODE"] = dtTmp.Rows[i]["VIRTUAL_CODE"].ToString();
                        dr["VIRTUAL_NAME"] = dtTmp.Rows[i]["VIRTUAL_NAME"].ToString();
                        dr["PURCHASE_QTY"] = dtTmp.Rows[i]["PLAN_QTY"].ToString();
                        string strDate = string.Empty;
                        if (dtDetail != null)
                        {
                            DataRow[] FindRows = dtDetail.Select("ITEM='" + sItem + "' And PERIOD='" + sPeriod + "'");
                            if (FindRows.Length > 0)
                            {
                                strDate = FindRows[0]["PLAN_ACCEPT_DATE"].ToString();
                            }
                        }
                        dr["PLAN_ACCEPT_DATE"] = strDate;
                        dr["COST"] = 0;
                        dr["MDC_QTY"] = 0;
                        dr["ACCEPT_ACCQTY"] = 0;
                        dr["MSG"] = "";
                        dtGift.Rows.Add(dr);
                        iAddRow++;
                    }
                }
                if (iAddRow > 0)
                    PUR022.Session["PUR02_Gift_" + sPageTimeStamp] = dtGift;
            }
        }
        return rtnValue;
    }