Пример #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
    }
Пример #2
0
    protected void Btn_Insert_Click(object sender, EventArgs e)
    {
        try
        {
            int iPageIndex;
            if (this.gv_Detail.EditIndex != -1)
            {
                ShowErrorMessage("請將編輯的資料列做更新,再按[儲存]");
            }
            else
            {
                DataTable Dt = (DataTable)Session["STM23_DTL_" + PageTimeStamp.Value];
                int intDEL_CNT = 0;

                if (Dt == null || Dt.Rows.Count == 0)
                {
                    STMModel.MaintainRouteLine bco = new STMModel.MaintainRouteLine(ConnectionDB);
                    Dt = bco.QuerySchema();
                }

                foreach (DataRow dr in Dt.Rows)
                {
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        intDEL_CNT++;
                    }
                }

                DataRow dRow = Dt.NewRow();

                dRow["CHAN_NO"] = System.DBNull.Value;
                dRow["STORE"] = System.DBNull.Value; ;
                dRow["ARRIVE_TIME"] = System.DBNull.Value; ;
                dRow["Route"] = this.Route.Text;
                dRow["EFF_START"] = this.EFF_START.Text;

                Dt.Rows.Add(dRow);

                Session["STM23_DTL_" + PageTimeStamp.Value] = Dt;
                if (Dt.Rows.Count > 0)
                {
                    double dbTemp = Dt.Rows.Count / gv_Detail.PageSize;
                    iPageIndex = Int32.Parse(Math.Truncate(dbTemp).ToString());
                }
                else
                {
                    iPageIndex = 0;
                }

                this.gv_Detail.PageIndex = iPageIndex;
                this.setGV((Dt.Rows.Count - intDEL_CNT > gv_Detail.PageSize ? (Dt.Rows.Count - intDEL_CNT - (gv_Detail.PageSize * gv_Detail.PageIndex) - 1) : Dt.Rows.Count - intDEL_CNT - 1), Dt, true);
            }

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { SetPageStatus(); }
    }
Пример #3
0
    }//databind_Mst

    /// <summary>
    /// 繫結資料 DTL
    /// </summary>
    private void databind_Dtl()
    {
        #region
        try
        {
            STMModel.MaintainRouteLine BCO = new STMModel.MaintainRouteLine(ConnectionDB);

            ParameterList.Clear();

            ParameterList.Add(this.hiddenROUTE.Value);
            ParameterList.Add(this.hiddenEFF_START.Value);

            DataTable Dt = BCO.QueryRouteLineByPK(ParameterList);

            #region 將明細資料放至DetailDt中
            Session["STM23_DTL_" + PageTimeStamp.Value] = Dt;


            #endregion

            #region 使用XML放置到前端資料
            DataSet Ds = Dt.DataSet;
            DetailOLDData.InnerHtml = Ds.GetXml();

            #endregion

            this.setGV(-1, Dt, false);


        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        #endregion
    }//databind_Dtl