/// <summary>
        /// 初始貨部件樹節點
        /// </summary>
        /// <param name="p_objNode"></param>
        /// <param name="p_strEnquipMentNum"></param>
        /// <remarks>(NO:0005078) Add By Leothlik TonyWu On 18/07/2014</remarks>
        private void InitEquipmentNode(IList<CodeMaster_cmt_Info> p_lisSource, TreeNode p_objNode, string p_strPreEquipmentNum)
        {
            var l_lisEquipment = p_lisSource.Where(p => p.cmt_cRemark2 == p_strPreEquipmentNum);

            foreach (var l_objEquipment in l_lisEquipment)
            {
                TreeNode l_objItem = new TreeNode(l_objEquipment.cmt_cRemark);

                var l_objPreItem = p_objNode.Tag as MaintainPlanEquipmentMapping_mpe_Info;

                MaintainPlanEquipmentMapping_mpe_Info l_objRootItem = new MaintainPlanEquipmentMapping_mpe_Info()
                {
                    mpe_cEquipmentName = l_objEquipment.cmt_cRemark,
                    mpe_cEquipmentNum = l_objEquipment.cmt_cValue,
                    mpe_cFullName = l_objPreItem.mpe_cPreEquipmentNum == "" ? l_objEquipment.cmt_cRemark : l_objPreItem.mpe_cFullName + "\\" + l_objEquipment.cmt_cRemark,
                    mpe_cFullNum = l_objPreItem.mpe_cPreEquipmentNum == "" ? l_objEquipment.cmt_cValue : l_objPreItem.mpe_cFullNum + "\\" + l_objEquipment.cmt_cValue,
                    mpe_cPreEquipmentNum = l_objPreItem.mpe_cEquipmentNum,
                    mpe_cRootEquipmentNum = l_objPreItem.mpe_cRootEquipmentNum
                };

                l_objItem.Tag = l_objRootItem;

                _BaseEquipmentList.Add(l_objRootItem);

                InitEquipmentNode(p_lisSource, l_objItem, l_objEquipment.cmt_cValue);

                p_objNode.Nodes.Add(l_objItem);
            }
        }
        /// <summary>
        /// 初始化部件樹
        /// </summary>
        /// <remarks>(NO:0005078) Add By Leothlik TonyWu On 18/07/2014</remarks>
        private void IintEquipmentList()
        {
            CodeMaster_cmt_Info l_objNormal = _codeMasterBL.GetCodeMasters(CustEnum.System.HBManager, CustEnum.KEY1.MaintainValue, CustEnum.KEY2.NormalMachine)[0];

            var l_strPrintNum = l_objNormal.cmt_cValue;
            var l_strPrintName = l_objNormal.cmt_cRemark;
            var l_lisEquipment = _codeMasterBL.GetCodeMasters(CustEnum.System.HBManager, CustEnum.KEY1.MaximoMachine);

            trvEqmipment.Nodes.Clear();

            MaintainPlanEquipmentMapping_mpe_Info l_objRootItem = new MaintainPlanEquipmentMapping_mpe_Info()
            {
                mpe_cEquipmentName = l_strPrintName,
                mpe_cEquipmentNum = l_strPrintNum,
                mpe_cFullName = l_strPrintName,
                mpe_cFullNum = l_strPrintNum,
                mpe_cPreEquipmentNum = "",
                mpe_cRootEquipmentNum = l_strPrintNum
            };

            _BaseEquipmentList.Add(l_objRootItem);

            TreeNode l_objItem = new TreeNode(l_strPrintName);
            l_objItem.Tag = l_objRootItem;

            InitEquipmentNode(l_lisEquipment, l_objItem, l_strPrintNum);

            trvEqmipment.Nodes.Add(l_objItem);
        }
        /// <summary>
        /// 取得已經選擇的部件清單
        /// </summary>
        /// <param name="p_objTarget"></param>
        /// <param name="p_lisCheckedNode"></param>
        /// <remarks>(NO:0005078) Add By Leothlik TonyWu On 18/07/2014</remarks>
        private bool GetCheckedNode(TreeNode p_objTarget)
        {
            var l_objItem = p_objTarget.Tag as MaintainPlanEquipmentMapping_mpe_Info;

            MaintainPlanEquipmentMapping_mpe_Info l_objCheckedItem = new MaintainPlanEquipmentMapping_mpe_Info()
            {
                mpe_cAddBy = base.UserInformation.usm_cUserLoginID,
                mpe_cEquipmentName = l_objItem.mpe_cEquipmentName,
                mpe_cFullName = l_objItem.mpe_cFullName,
                mpe_cEquipmentNum = l_objItem.mpe_cEquipmentNum,
                mpe_cRootEquipmentNum = l_objItem.mpe_cRootEquipmentNum,
                mpe_cFullNum = l_objItem.mpe_cFullNum,
                mpe_cPreEquipmentNum = l_objItem.mpe_cPreEquipmentNum,
                mpe_cLastBy = base.UserInformation.usm_cUserLoginID,
                mpe_cRecordID = Guid.NewGuid(),
                mpe_dAddDate = DateTime.Now,
                mpe_dLastDate = DateTime.Now,
                mpe_iMOMID = 0,
                mpe_lIsDelete = false,
                RecordID = 0
            };

            MaintainPlanEquipmentMapping_mpe_Info info = _PlanEquipmentList.FirstOrDefault(t => t.mpe_cEquipmentNum == l_objCheckedItem.mpe_cEquipmentNum);

            if (info == null)
            {
                _PlanEquipmentList.Add(l_objCheckedItem);
            }

            return true;
        }
Example #4
0
        /// <summary>
        /// 獲取保養動作所對應的部件
        /// </summary>
        /// <returns></returns>
        public List<MaintainPlanEquipmentMapping_mpe_Info> GetMaintainOperationEquipment()
        {
            List<MaintainPlanEquipmentMapping_mpe_Info> list = new List<MaintainPlanEquipmentMapping_mpe_Info>();
            StringBuilder strSql = new StringBuilder();
            strSql.AppendLine("select ");
            strSql.AppendLine("mpe_cRecordID,mpe_iMOMID, mpe_cEquipmentNum, mpe_cEquipmentName, mpe_cPreEquipmentNum, mpe_cRootEquipmentNum, mpe_cFullName, mpe_cFullNum,mpe_dLastDate ");
            strSql.AppendLine("from MaintainPlanEquipmentMapping_mpe ");
            strSql.AppendLine("where mpe_lIsDelete=0 ");

            try
            {
                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        MaintainPlanEquipmentMapping_mpe_Info model = new MaintainPlanEquipmentMapping_mpe_Info();
                        if (sdr["mpe_cRecordID"] != null && sdr["mpe_cRecordID"].ToString() != "")
                        {
                            model.mpe_cRecordID = new Guid(sdr["mpe_cRecordID"].ToString());
                        }
                        if (sdr["mpe_iMOMID"] != null && sdr["mpe_iMOMID"].ToString() != "")
                        {
                            model.mpe_iMOMID = int.Parse(sdr["mpe_iMOMID"].ToString());
                        }
                        if (sdr["mpe_cEquipmentNum"] != null && sdr["mpe_cEquipmentNum"].ToString() != "")
                        {
                            model.mpe_cEquipmentNum = sdr["mpe_cEquipmentNum"].ToString();
                        }
                        if (sdr["mpe_cEquipmentName"] != null && sdr["mpe_cEquipmentName"].ToString() != "")
                        {
                            model.mpe_cEquipmentName = sdr["mpe_cEquipmentName"].ToString();
                        }
                        if (sdr["mpe_cPreEquipmentNum"] != null && sdr["mpe_cPreEquipmentNum"].ToString() != "")
                        {
                            model.mpe_cPreEquipmentNum = sdr["mpe_cPreEquipmentNum"].ToString();
                        }
                        if (sdr["mpe_cRootEquipmentNum"] != null && sdr["mpe_cRootEquipmentNum"].ToString() != "")
                        {
                            model.mpe_cRootEquipmentNum = sdr["mpe_cRootEquipmentNum"].ToString();
                        }
                        if (sdr["mpe_cFullName"] != null && sdr["mpe_cFullName"].ToString() != "")
                        {
                            model.mpe_cFullName = sdr["mpe_cFullName"].ToString();
                        }
                        if (sdr["mpe_cFullNum"] != null && sdr["mpe_cFullNum"].ToString() != "")
                        {
                            model.mpe_cFullNum = sdr["mpe_cFullNum"].ToString();
                        }

                        if (sdr["mpe_dLastDate"] != null && sdr["mpe_dLastDate"].ToString() != "")
                        {
                            model.mpe_dLastDate = DateTime.Parse(sdr["mpe_dLastDate"].ToString());
                        }

                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Add By Ximonliang
        /// </summary>
        /// <param name="info"></param>
        /// <param name="sqlTrans"></param>
        /// <returns></returns>
        public bool InsertMaintainPlanEquipmentMapping(MaintainPlanEquipmentMapping_mpe_Info info, SqlTransaction sqlTrans)
        {
            string strSql = string.Empty;

            if (info != null && sqlTrans != null)
            {
                strSql += "Insert into MaintainPlanEquipmentMapping_mpe" + Environment.NewLine;
                strSql += "(mpe_cRecordID, mpe_iMOMID, mpe_cEquipmentNum, mpe_cEquipmentName, mpe_cPreEquipmentNum, mpe_cRootEquipmentNum, mpe_cFullName, mpe_cFullNum, mpe_lIsDelete, mpe_cAddBy, mpe_dAddDate, mpe_cLastBy, mpe_dLastDate)" + Environment.NewLine;
                strSql += "values" + Environment.NewLine;
                strSql += "('" + info.mpe_cRecordID.ToString() + "'," + info.mpe_iMOMID + ",'" + info.mpe_cEquipmentNum + "','" + info.mpe_cEquipmentName + "','" + info.mpe_cPreEquipmentNum + "','" + info.mpe_cRootEquipmentNum + "','" + info.mpe_cFullName + "','" + info.mpe_cFullNum + "',0,'" + info.mpe_cAddBy + "',getdate(),'" + info.mpe_cLastBy + "',getdate())" + Environment.NewLine;

                try
                {
                    return ExecuteSQL(strSql, sqlTrans);
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return false;
        }
        /// <summary>
        /// 取得保養項目對應的部件
        /// </summary>
        /// <param name="p_intMOMID"></param>
        /// <returns></returns>
        /// <remarks>(NO:0005078) Add By Leothlink TonyWu On 07/18/2014</remarks>
        public List<MaintainPlanEquipmentMapping_mpe_Info> GetPlanMaintainEquipments(int p_intMOMID)
        {
            List<MaintainPlanEquipmentMapping_mpe_Info> l_lisReturn = new List<MaintainPlanEquipmentMapping_mpe_Info>();

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;
            strSql += "select * " + Environment.NewLine;
            strSql += "from MaintainPlanEquipmentMapping_mpe NOLOCK" + Environment.NewLine;
            strSql += "where mpe_iMOMID=" + p_intMOMID + Environment.NewLine;

            try
            {
                using (SqlDataReader reader = DbHelperSQL.ExecuteReader(strSql))
                {
                    while (reader.Read())
                    {
                        MaintainPlanEquipmentMapping_mpe_Info info = new MaintainPlanEquipmentMapping_mpe_Info();

                        #region 實體賦值
                        if (reader["mpe_cRecordID"] != null && reader["mpe_cRecordID"].ToString() != string.Empty)
                        {
                            info.mpe_cRecordID = new Guid(reader["mpe_cRecordID"].ToString().Trim());
                        }

                        if (reader["mpe_iMOMID"] != null && reader["mpe_iMOMID"].ToString() != string.Empty)
                        {
                            info.mpe_iMOMID = Convert.ToInt32(reader["mpe_iMOMID"].ToString().Trim());
                        }

                        if (reader["mpe_cEquipmentNum"] != null && reader["mpe_cEquipmentNum"].ToString() != string.Empty)
                        {
                            info.mpe_cEquipmentNum = reader["mpe_cEquipmentNum"].ToString().Trim();
                        }

                        if (reader["mpe_cEquipmentName"] != null && reader["mpe_cEquipmentName"].ToString() != string.Empty)
                        {
                            info.mpe_cEquipmentName = reader["mpe_cEquipmentName"].ToString().Trim();
                        }

                        if (reader["mpe_cPreEquipmentNum"] != null && reader["mpe_cPreEquipmentNum"].ToString() != string.Empty)
                        {
                            info.mpe_cPreEquipmentNum = reader["mpe_cPreEquipmentNum"].ToString().Trim();
                        }

                        if (reader["mpe_cRootEquipmentNum"] != null && reader["mpe_cRootEquipmentNum"].ToString() != string.Empty)
                        {
                            info.mpe_cRootEquipmentNum = reader["mpe_cRootEquipmentNum"].ToString().Trim();
                        }

                        if (reader["mpe_cFullName"] != null && reader["mpe_cFullName"].ToString() != string.Empty)
                        {
                            info.mpe_cFullName = reader["mpe_cFullName"].ToString().Trim();
                        }

                        if (reader["mpe_cFullNum"] != null && reader["mpe_cFullNum"].ToString() != string.Empty)
                        {
                            info.mpe_cFullNum = reader["mpe_cFullNum"].ToString().Trim();
                        }

                        if (reader["mpe_lIsDelete"] != null && reader["mpe_lIsDelete"].ToString() != string.Empty)
                        {
                            info.mpe_lIsDelete = (reader["mpe_lIsDelete"].ToString().Trim() == "1" ? true : false);
                        }

                        if (reader["mpe_cAddBy"] != null && reader["mpe_cAddBy"].ToString() != string.Empty)
                        {
                            info.mpe_cAddBy = reader["mpe_cAddBy"].ToString().Trim();
                        }

                        if (reader["mpe_dAddDate"] != null && reader["mpe_dAddDate"].ToString() != string.Empty)
                        {
                            info.mpe_dAddDate = Convert.ToDateTime(reader["mpe_dAddDate"].ToString().Trim());
                        }

                        if (reader["mpe_cLastBy"] != null && reader["mpe_cLastBy"].ToString() != string.Empty)
                        {
                            info.mpe_cLastBy = reader["mpe_cLastBy"].ToString().Trim();
                        }

                        if (reader["mpe_dLastDate"] != null && reader["mpe_dLastDate"].ToString() != string.Empty)
                        {
                            info.mpe_dLastDate = Convert.ToDateTime(reader["mpe_dLastDate"].ToString().Trim());
                        }
                        #endregion

                        l_lisReturn.Add(info);
                    }
                }
            }
            catch (Exception Ex)
            {

                throw Ex;
            }
            //Add By Ximonliang 2015-03-09------------------------<<

            #region 舊代碼
            //using (MainDBDataContext db = new MainDBDataContext())
            //{
            //    var l_lisResult = db.MaintainPlanEquipmentMapping_mpe.Where(p => p.mpe_iMOMID == p_intMOMID).ToList();

            //    foreach (var l_objItem in l_lisResult)
            //    {
            //        var l_objConvertItem = Common.General.CopyObjectValue<MaintainPlanEquipmentMapping_mpe, MaintainPlanEquipmentMapping_mpe_Info>(l_objItem);

            //        l_lisReturn.Add(l_objConvertItem);
            //    }
            //}
            #endregion

            return l_lisReturn;
        }