Ejemplo n.º 1
0
 public string GetLocateSecByAttr(ArrayList ParameterList)
 {
     try
     {
         string LocateSection = string.Empty;
         DBOINV.MaintainStockTmpLocate BCOINV = new DBOINV.MaintainStockTmpLocate(strConn);
         LocateSection = BCOINV.QueryLocateByAttr(ParameterList);
         return LocateSection;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        //IVM152.aspx
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ParameterList">UserID,PickDate,RemoveNo (移轉單號),ELocateNo(上架儲區),ELocateSec (上架儲位,可Null)</param>
        /// <param name="RootDBT"></param>
        /// <param name="OK"></param>
        /// <param name="PickNo"></param>
        /// <returns></returns>
        public bool CreateByTrans(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 PickDataNo = string.Empty;
            string UserID = ParameterList[0].ToString();
            string PickDate = ParameterList[1].ToString();
            string RemoveNo = ParameterList[2].ToString();
            string ELocateNo = ParameterList[3].ToString();
            string ELocateSec = ParameterList[4].ToString();

            string LocateAttr = string.Empty;

            try
            {
                DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB);
                DBOINV.MaintainStockTmpLocate INVDBO = new DBOINV.MaintainStockTmpLocate(strConn);
                DBOINV.RecordingStockStatement INVDBO2 = new DBOINV.RecordingStockStatement(strConn);

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

                #region 啟動交易或指定RootTranscation

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

                #endregion

                //取得應揀貨資料
                DataTable dtPickData = IVMDBO.GetRemovePickData(RemoveNo);

                if (dtPickData.Rows.Count == 0)
                {
                    OK = "0";
                    PickNo = "";
                    return false;
                }
                else
                {
                    for (int i = 0; i < dtPickData.Rows.Count; i++)
                    {
                        if (int.Parse(dtPickData.Rows[i]["onhd_qty"].ToString()) < int.Parse(dtPickData.Rows[i]["IniPickQty"].ToString()))
                        {
                            OK = "2";
                        }
                    }
                }

                if (OK != "2")
                {
                    OK = "1";
                }

                for (int i = 0; i < dtPickData.Rows.Count; i++)
                {
                    if (dtPickData.Rows[i]["BLocateNo"].ToString() != ELocateNo) //上下不同儲區,一定要上到入庫暫存儲位
                    {
                        DBOPara.Clear();
                        DBOPara.Add(ELocateNo);
                        DBOPara.Add("1");
                        string TempELocate = INVDBO.QueryLocateByAttr(DBOPara);
                        dtPickData.Rows[i]["ELocateSec"] = TempELocate;
                        if (TempELocate.Length > 0)
                        {
                            dtPickData.Rows[i]["ELocateNo"] = TempELocate.Substring(0,1);
                        }
                    }
                    else //上下同儲區
                    {
                        //
                        if (ELocateSec != string.Empty && ELocateSec.Length == 5 ) //上下同儲區,而使用者又指定上架儲位的狀況下,依使用者所指定
                        {
                            dtPickData.Rows[i]["ELocateNo"] = ELocateNo;
                            dtPickData.Rows[i]["ELocateSec"] = ELocateNo+ELocateSec;
                        }
                        else //上下同儲區,使用者又未指定儲位
                        {
                            LocateAttr = string.Empty;
                            DBOPara.Clear();
                            DBOPara.Add(dtPickData.Rows[i]["BLocateSec"].ToString());
                            LocateAttr = INVDBO.QueryAttrByLocateSec(DBOPara);
                            if (LocateAttr == string.Empty) //表示下架儲位是一般儲位,所以要上到出庫暫存儲位
                            {
                                DBOPara.Clear();
                                DBOPara.Add(ELocateNo);
                                DBOPara.Add("2");
                                string TempELocate = INVDBO.QueryLocateByAttr(DBOPara);
                                dtPickData.Rows[i]["ELocateSec"] = TempELocate;
                                if (TempELocate != string.Empty)
                                {
                                    dtPickData.Rows[i]["ELocateNo"] = TempELocate.Substring(0, 1);
                                }
                            }
                            else //表示下架儲位是 出/入 庫暫存儲位,要上到一般儲格
                            { 
                                DBOPara.Clear();
                                DBOPara.Add(ELocateNo);
                                DBOPara.Add(dtPickData.Rows[i]["item"].ToString());
                                DBOPara.Add(dtPickData.Rows[i]["period"].ToString());
                                string GeneralELocate = INVDBO2.QueryMinStockSecCode(DBOPara);
                                dtPickData.Rows[i]["ELocateSec"] = GeneralELocate;
                                if (GeneralELocate != string.Empty)
                                {
                                    dtPickData.Rows[i]["ELocateNo"] = GeneralELocate.Substring(0, 1);
                                }
                                else
                                {
                                    dtPickData.Rows[i]["ELocateNo"] = ELocateNo;
                                }
                            }
                        }
                    }
                }

                DataView dv = new DataView(dtPickData);
                dv.Sort="BLOCATENO,ELOCATENO asc";
                DataTable dtInsert = dv.ToTable();

                ArrayList LocateNoList = new ArrayList();

                //取得儲位類型 BLocateNo + ElocateNo不同視為相異
                for (int i = 0; i < dtInsert.Rows.Count;i++ )
                {
                    string BNo = dtInsert.Rows[i]["BLOCATENO"].ToString();
                    string ENo = dtInsert.Rows[i]["ELOCATENO"].ToString();

                    bool InList = false;
                    for (int j = 0; j < LocateNoList.Count; j++)
                    {
                        InList = false;
                        string BNO = LocateNoList[j].ToString().Split(',')[0];
                        string ENO = LocateNoList[j].ToString().Split(',')[1];

                        if (BNo == BNO && ENo == ENO)
                        {
                            InList = true; 
                        }
                    }
                    if (InList == false)
                        LocateNoList.Add(BNo + "," + ENo);
                }

                for (int i = 0; i < LocateNoList.Count; i++)
                {
                    string TempPickNo = string.Empty;
                    int TempMainID = -1;

                    string NewBNo = LocateNoList[i].ToString().Split(',')[0];
                    string NewENO = LocateNoList[i].ToString().Split(',')[1];

                    int TempInsertCount = 0;
                    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("1","int",false));
                    DBOPara.Add(GetValueSetParameter(RemoveNo,"string",false));
                    TempInsertCount = IVMDBO.CreatePickMain(DBOPara, DBT, out TempMainID, out TempPickNo);

                    if (TempInsertCount == 0)
                    {
                        throw new Exception("新增揀貨單主檔失敗");
                    }

                    for (int j = 0; j < dtInsert.Rows.Count; j++)
                    {
                        if (NewBNo == dtInsert.Rows[j]["BLOCATENO"].ToString() && NewENO == dtInsert.Rows[j]["ELOCATENO"].ToString())
                        {
                            string item = dtInsert.Rows[j]["item"].ToString();
                            string period = dtInsert.Rows[j]["period"].ToString();
                            int onhd_qty = int.Parse(dtInsert.Rows[j]["onhd_qty"].ToString());
                            int IniPickQty = int.Parse(dtInsert.Rows[j]["IniPickQty"].ToString());
                            int RealPickQty = int.Parse(dtInsert.Rows[j]["IniPickQty"].ToString());
                            string strBLocateNo = dtInsert.Rows[j]["BLOCATENO"].ToString();
                            string strBLocateSec = dtInsert.Rows[j]["BLOCATESEC"].ToString();
                            string strELocateNo = dtInsert.Rows[j]["ELOCATENO"].ToString();
                            string strELocateSec = dtInsert.Rows[j]["ELOCATESEC"].ToString();

                            DBOPara.Clear();
                            DBOPara.Add(GetValueSetParameter(UserID,"string",false));
                            DBOPara.Add(GetValueSetParameter(PickDate,"string",false));
                            DBOPara.Add(GetValueSetParameter(TempMainID.ToString(),"string",false));
                            DBOPara.Add(GetValueSetParameter(item,"string",false));
                            DBOPara.Add(GetValueSetParameter(period,"string",false));
                            DBOPara.Add(GetValueSetParameter(onhd_qty.ToString(),"int",false));
                            DBOPara.Add(GetValueSetParameter(IniPickQty.ToString(),"int",false));
                            DBOPara.Add(GetValueSetParameter(RealPickQty.ToString(),"int",false));
                            DBOPara.Add(GetValueSetParameter(strBLocateNo,"string",false));
                            DBOPara.Add(GetValueSetParameter(strBLocateSec,"string",false));
                            DBOPara.Add(GetValueSetParameter(strELocateNo,"string",false));
                            DBOPara.Add(GetValueSetParameter(strELocateSec,"string",false));
                            DBOPara.Add(GetValueSetParameter("","int",false));
                            IVMDBO.CreatePickDetl(DBOPara, DBT);
                        }
                    }

                    DBOPara.Clear();
                    DBOPara.Add(GetValueSetParameter(UserID, "string", false));
                    DBOPara.Add(GetValueSetParameter(PickDate, "string", false));
                    DBOPara.Add(GetValueSetParameter(TempMainID.ToString(), "int", false));
                    DBOPara.Add(GetValueSetParameter(TempPickNo, "string", false));
                    DBOPara.Add(GetValueSetParameter(RemoveNo, "string", false));
                    DBOPara.Add(GetValueSetParameter("1", "int", false));
                    IVMDBO.CreatePickMapNo(DBOPara, DBT);

                    PickNo += TempPickNo + ",";
                }

                #region 交易成功

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

                if (PickNo.Length > 0)
                {
                    PickNo = PickNo.Substring(0, PickNo.Length - 1);
                }

                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
            }
        }
Ejemplo n.º 3
0
 public string GetDefaultLocateSecByUse(string LocateUse)
 {
     string LocateNo = string.Empty;
     string LocateSec = string.Empty;
     try
     {
         DBOINV.MaintainStockTmpLocate INVDBO = new DBOINV.MaintainStockTmpLocate(strConn);
         ArrayList ParameterList = new ArrayList();
         ParameterList.Add(LocateUse);
         INVDBO.QueryLocateByUse(ParameterList, out LocateNo, out LocateSec);
         return LocateSec;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public string GetMinStockLocateIn()
 {
     string LocateSecIn = "";
     try
     {
         DBOINV.MaintainStockTmpLocate INVDBO = new DBOINV.MaintainStockTmpLocate(strConn);
         ArrayList ParameterList = new ArrayList();
         string MinStockLocateNo = INVDBO.QueryMinStockLocateNo(ParameterList);
         ParameterList.Clear();
         ParameterList.Add(MinStockLocateNo);
         ParameterList.Add("1");
         LocateSecIn = INVDBO.QueryLocateByAttr(ParameterList);
         return LocateSecIn;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 5
0
 public string GetDefaultLocateByAttr(ArrayList ParameterList)
 {
     string LocateSec = string.Empty;
     try
     {
         DBOINV.MaintainStockTmpLocate INVDBO = new DBOINV.MaintainStockTmpLocate(strConn);
         LocateSec = INVDBO.QueryLocateByAttr(ParameterList);
         return LocateSec;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 6
0
    /// <summary>
    /// 取得LocateSection,存入ViewState
    /// </summary>
    private void GetLocateSection()
    {
        try
        {
            string LocateNo = string.Empty;
            string LocateSection = string.Empty;

            PIC.VDS2G.GFM.INV.MaintainStockTmpLocate BCO = new PIC.VDS2G.GFM.INV.MaintainStockTmpLocate(ConntionDB);

            ParameterList.Clear();

            ParameterList.Add("D");

            BCO.QueryLocateByUse(ParameterList, out LocateNo, out LocateSection);

            if (LocateNo.Length == 0)
            {
                ErrorMsgLabel.Text = "請先設定門退入庫儲位";
                btnSearch.Enabled = false;
            }
            else
            {
                ViewState["LocateSection"] = LocateSection;
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.IndexOf("請先設定此功能別對應的儲位") != -1)
            {
                ErrorMsgLabel.Text = "請先設定門退入庫儲位";
            }
            else
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            btnSearch.Enabled = false;
            btnCancel.Enabled = false;
        }
    }
Ejemplo n.º 7
0
    public static string QueryLocate(string LocateNO)
    {
        PIC.VDS2G.GFM.INV.MaintainStockTmpLocate BCO = new PIC.VDS2G.GFM.INV.MaintainStockTmpLocate(ConntionDB);

        ParameterList.Clear();

        ParameterList.Add(LocateNO);
        ParameterList.Add("1");

        string strResult = BCO.QueryLocateByAttr(ParameterList);

        return strResult;
    }
Ejemplo n.º 8
0
 //取得廠退使用儲區(LocateSection)
 public void QueryTargetLocate(ArrayList ParameterList, out string LocateNo, out string LocateSection)
 {
     try
     {
         INVDBO.MaintainStockTmpLocate db = new INVDBO.MaintainStockTmpLocate(strConn);
         ParameterList.Clear();
         ParameterList.Add("B");
         db.QueryLocateByUse(ParameterList, out LocateNo, out LocateSection);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
        public string GetSugLocate(string LocateSection, string item, string period)
        {
            ArrayList ParameterList = new ArrayList();
            string InLocateSection = "";
            string OutLocateSection = "";

            DBOINV.MaintainStockTmpLocate dbo = new DBOINV.MaintainStockTmpLocate(strConn);
            ParameterList.Clear();
            ParameterList.Add(LocateSection.Substring(0, 1));
            ParameterList.Add("1");
            InLocateSection = dbo.QueryLocateByAttr(ParameterList);

            //DBOINV.MaintainStockTmpLocate dbo = new DBOINV.MaintainStockTmpLocate(strConn);
            ParameterList.Clear();
            ParameterList.Add(LocateSection.Substring(0, 1));
            ParameterList.Add("2");
            OutLocateSection = dbo.QueryLocateByAttr(ParameterList);

            if (LocateSection == InLocateSection || LocateSection == OutLocateSection)
            {
                DBO.RemoveData dboIVM = new RemoveData(ref USEDB);
                ParameterList.Clear();
                ParameterList.Add(LocateSection.Substring(0, 1));
                ParameterList.Add(item);
                ParameterList.Add(period);
                return dboIVM.QueryMinStockSecCode(ParameterList);
            }
            else
            {
                return OutLocateSection;
            }

        }