Example #1
0
    public static string checkStoreData(string ROUTE, string EFF_START, string EFF_END, string CHAN_NO, string stordID, string id, string PageTimeStamp)
    {
        #region
        String rtnValue = "";
        if (stordID != "")
        {

            STMModel.MaintainRouteLine bco = new STMModel.MaintainRouteLine(ConnectionDB);
            int intDUP = 0;

            //當id不等於空白,表示已存在資料庫中
            if (id != "")
            {
                // 查詢PK是否存在且是否為同一筆id
                ParameterList.Clear();
                ParameterList.Add(ROUTE);
                ParameterList.Add(EFF_START);
                ParameterList.Add(CHAN_NO);
                ParameterList.Add(stordID);
                ParameterList.Add(id);
                DataTable countsDt = bco.QueryExistDB(ParameterList);
                if (countsDt.Rows.Count > 0)
                {
                    rtnValue = CHAN_NO + "|" + stordID + "|" + "transFail";
                }
            }
            else
            {
                //查詢PK是否存在
                ParameterList.Clear();
                ParameterList.Add(ROUTE);
                ParameterList.Add(EFF_START);
                ParameterList.Add(CHAN_NO);
                ParameterList.Add(stordID);
                DataTable countsDt = bco.QueryExistPK(ParameterList);
                if (countsDt.Rows.Count > 0)
                {
                    DataTable dt = (DataTable)HttpContext.Current.Session["STM23_DTL_" + PageTimeStamp];
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr.RowState != DataRowState.Deleted)
                        {
                            if (dr["CHAN_NO"].ToString() == CHAN_NO && dr["STORE"].ToString() == stordID)
                            {
                                intDUP++;
                            }
                        }
                    }

                    if (intDUP > 0)
                    {
                        rtnValue = CHAN_NO + "|" + stordID + "|" + "transFail";
                    }
                }
            }
            if (rtnValue == "")
            {
                ParameterList.Clear();
                ParameterList.Add(CHAN_NO);
                ParameterList.Add(stordID);

                // 查詢是否存在VDS_STM_STORE_UNIQUE
                DataTable countsDt = bco.CheckStore(ParameterList);
                if (countsDt.Rows.Count == 0)
                {
                    rtnValue = CHAN_NO + "|" + stordID + "|" + "fail";
                }
            }
            if (rtnValue == "")
            {
                ParameterList.Clear();
                ParameterList.Add(ROUTE);
                ParameterList.Add(CHAN_NO);
                ParameterList.Add(stordID);
                ParameterList.Add(EFF_START);
                ParameterList.Add(EFF_END);

                //在生效中的路線,應不可存在同樣的門市資料
                DataTable DupStoreDt = bco.CheckDupStore(ParameterList);
                if (DupStoreDt.Rows[0][0].ToString() == "0")
                {
                    rtnValue = CHAN_NO + "|" + stordID + "|" + "ok";
                }
                else
                {
                    rtnValue = CHAN_NO + "|" + stordID + "|" + "dupfail";
                }
            }
        }

        return rtnValue;
        #endregion
    }