Esempio n. 1
0
 //IVM155.aspx
 public DataTable GetAcceptNoByStockIn(ArrayList ParameterList)
 {
     try
     {
         DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB);
         return IVMDBO.GetAcceptNoByStockIn(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        //IVM155.aspx
        /// <summary>
        /// 依照驗收單資料建立揀貨單
        /// </summary>
        /// <param name="ParameterList">UserID,PickDate,BMapNo,EMapNo,BLocateSec,ELocateSec</param>
        /// <param name="RootDBT">傳入的交易</param>
        /// <param name="OK">OK FLAG 0.無資料 1.完成 2.揀貨數量不符</param>
        /// <param name="PickNo"></param>
        /// <returns></returns>
        public bool CreateByStockIn(ArrayList ParameterList, DbTransaction RootDBT, out string OK, out string PickNo)
        {
            OK = string.Empty;
            PickNo = string.Empty;
            string PickDataNo = "";
            ArrayList DBOPara = new ArrayList();
            bool IsRootTranscation = false;
            int PID = -1;

            string UserID = ParameterList[0].ToString();
            string PickDate = ParameterList[1].ToString();
            string BMapNo = ParameterList[2].ToString();
            string EMapNo = ParameterList[3].ToString();
            string BLocateSec = ParameterList[4].ToString();
            string ELocateSec = ParameterList[5].ToString();

            string BLocateNo = string.Empty;
            if (BLocateSec.Length > 0)
                BLocateNo = BLocateSec.Substring(0, 1);

            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

                //取得AcceptNo(有可能會有多筆)
                DBOPara.Clear();
                DBOPara.Add(GetValueSetParameter(BMapNo, "string", false));
                DBOPara.Add(GetValueSetParameter(EMapNo, "string", false));

                DataTable dtAcceptNo = IVMDBO.GetAcceptNoByStockIn(DBOPara);

                DBOPara.Clear();
                DBOPara.Add(GetValueSetParameter(BMapNo, "string", false));
                DBOPara.Add(GetValueSetParameter(EMapNo, "string", false));
                DBOPara.Add(GetValueSetParameter(BLocateSec, "string", false));

                DataTable dtPickData = IVMDBO.GetPickDataByStockIn(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("", "string", false));
                DBOPara.Add(GetValueSetParameter(PickDate, "string", false));
                DBOPara.Add(GetValueSetParameter("4", "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(BLocateNo, "string", false));
                    DBOPara.Add(GetValueSetParameter(BLocateSec, "string", false));
                    DBOPara.Add(GetValueSetParameter(ELocateNo, "string", false));
                    DBOPara.Add(GetValueSetParameter(ELocateSec, "string", false));
                    DBOPara.Add(GetValueSetParameter("", "int", false));

                    IVMDBO.CreatePickDetl(DBOPara, DBT);
                }

                for (int j = 0; j < dtAcceptNo.Rows.Count; j++)
                { 
                    DBOPara.Clear();
                    DBOPara.Add(GetValueSetParameter(UserID, "string", false));
                    DBOPara.Add(GetValueSetParameter(PickDate, "string", false));
                    DBOPara.Add(GetValueSetParameter(PID.ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(PickNo, "string", false));
                    DBOPara.Add(GetValueSetParameter(dtAcceptNo.Rows[j]["AcceptNo"].ToString(), "string", false));
                    DBOPara.Add(GetValueSetParameter("4", "int", false));
                    IVMDBO.CreatePickMapNo(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
            }
        }