コード例 #1
0
        //IVM156.aspx
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ParameterList">UserID、PickDate、Supplier、RootNo、BLocateNo、BLocateSec、ELocateSec</param>
        /// <param name="RootDBT"></param>
        /// <param name="OK"></param>
        /// <param name="PickNo"></param>
        /// <returns></returns>
        public bool CreateBySupplier(ArrayList ParameterList, DbTransaction RootDBT, out string OK, out string PickNo)
        {
            OK = string.Empty;
            PickNo = string.Empty;
            ArrayList DBOPara = new ArrayList();
            bool IsRootTranscation = false;
            int PID = -1;

            string UserID = ParameterList[0].ToString();
            string PickDate = ParameterList[1].ToString();
            string Supplier = ParameterList[2].ToString();
            string RootNo = ParameterList[3].ToString();
            string BLocateNo = ParameterList[4].ToString();
            string BLocateSec = ParameterList[5].ToString();
            string ELocateSec = ParameterList[6].ToString();

            string ELocateNo = string.Empty;
            if (ELocateSec.Length > 0)
                ELocateNo = ELocateSec.Substring(0, 1);

            try
            {
                DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB);

                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                DBOPara.Clear();
                DBOPara.Add(GetValueSetParameter(Supplier, "string", false));
                DBOPara.Add(GetValueSetParameter(RootNo, "string", false));
                DBOPara.Add(GetValueSetParameter(BLocateNo, "string", false));
                DBOPara.Add(GetValueSetParameter(BLocateSec, "string", false));
                DBOPara.Add(GetValueSetParameter(ELocateSec, "string", false));

                DataTable dtPickData = IVMDBO.GetPickDatabySupplier(DBOPara);

                if (dtPickData.Rows.Count == 0)
                {
                    OK = "0";
                    PickNo = "";
                    return false;
                }
                else
                {
                    OK = "1";
                }

                DBOPara.Clear();
                DBOPara.Add(GetValueSetParameter(UserID, "string", false));
                DBOPara.Add(GetValueSetParameter("", "string", false));
                DBOPara.Add(GetValueSetParameter(Supplier, "string", false));
                DBOPara.Add(GetValueSetParameter(PickDate, "string", false));
                DBOPara.Add(GetValueSetParameter("5", "int", false));
                DBOPara.Add(GetValueSetParameter("", "string", false));

                IVMDBO.CreatePickMain(DBOPara, DBT, out PID, out PickNo);

                for (int i = 0; i < dtPickData.Rows.Count; i++)
                {
                    DBOPara.Clear();
                    DBOPara.Add(GetValueSetParameter(UserID, "string", false));
                    DBOPara.Add(GetValueSetParameter(PickDate, "string", false));
                    DBOPara.Add(GetValueSetParameter(PID.ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["item"].ToString(), "string", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["period"].ToString(), "string", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["Onhd_Qty"].ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["IniPickQty"].ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["RealPickQty"].ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["BLocateNo"].ToString(), "string", false));
                    DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["BLocateSec"].ToString(), "string", false));
                    DBOPara.Add(GetValueSetParameter(ELocateNo, "string", false));
                    DBOPara.Add(GetValueSetParameter(ELocateSec, "string", false));
                    DBOPara.Add(GetValueSetParameter("", "int", false));

                    IVMDBO.CreatePickDetl(DBOPara, DBT);
                }

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                return true;

                #endregion
            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion
            }
        }
コード例 #2
0
 //IVM156.aspx
 public DataTable GetPickDatabySupplier(ArrayList ParameterList)
 {
     try
     {
         DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB);
         return IVMDBO.GetPickDatabySupplier(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }