Exemplo n.º 1
0
        public List<MaintainOperationMaster_mom_Info> FindRecord_ppc(MaintainOperationMaster_mom_Info info)
        {
            try
            {
                List<MaintainOperationMaster_mom_Info> listRes = new List<MaintainOperationMaster_mom_Info>();

                StringBuilder htrSql = new StringBuilder();
                htrSql.Append("from MaintainOperationMaster_mom_Info where 1=1 ");

                Dictionary<string, object> dicCondition = new Dictionary<string, object>();

                if (info != null)
                {
                    htrSql.AppendLine(" and mom_lIsAtive = :mom_lIsAtive ");
                    dicCondition.Add("mom_lIsAtive", info.mom_lIsAtive);
                }

                listRes = (List<MaintainOperationMaster_mom_Info>)FindEntities<MaintainOperationMaster_mom_Info>(htrSql.ToString(), dicCondition);

                return listRes;
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            bool isSuccess = false;
            MaintainOperationMaster_mom_Info info = new MaintainOperationMaster_mom_Info();
            info = KeyObject as MaintainOperationMaster_mom_Info;

            #region 舊代碼
            //using (MainDBDataContext db = new MainDBDataContext())
            //{
            //    MaintainOperationMaster_mom delTab = db.MaintainOperationMaster_mom.SingleOrDefault(t => t.mom_iRecordID == info.mom_iRecordID);
            //    if (delTab != null)
            //    {
            //        db.MaintainOperationMaster_mom.DeleteOnSubmit(delTab);
            //        db.SubmitChanges();
            //        isSuccess = true;
            //    }
            //}
            #endregion

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;

            if (info != null)
            {
                strSql += "delete from MaintainOperationMaster_mom" + Environment.NewLine;
                strSql += "where mom_iRecordID=" + info.mom_iRecordID + Environment.NewLine;

                using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                {
                    SqlTransaction transaction = null;
                    conn.Open(); //開啟連接
                    transaction = conn.BeginTransaction(); //開啟事務

                    try
                    {
                        isSuccess = ExecuteSQL(strSql, transaction);

                    }
                    catch (Exception Ex)
                    {
                        transaction.Rollback();
                        throw Ex;
                    }
                    finally
                    {
                        if (isSuccess)
                        {
                            transaction.Commit();
                        }
                    }
                }
            }

            //Add By Ximonliang 2015-03-09------------------------<<

            return isSuccess;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化當前項目
        /// </summary>
        private void InitModelInfo()
        {
            if (BaseParam != null)
            {
                _currentItem = BaseParam as MaintainOperationMaster_mom_Info;

            }
            else
            {
                _currentItem = new MaintainOperationMaster_mom_Info();
            }
            DisplayInfo(_currentItem);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 顯示資訊
        /// </summary>
        /// <param name="prepareModel"></param>
        private void DisplayInfo(MaintainOperationMaster_mom_Info operationModel)
        {
            MaintenanceInfoProprety mip = new MaintenanceInfoProprety();

            mip.mom_cOperationCode = operationModel.mom_cOperationCode;
            mip.mom_cMachineModel = operationModel.mom_cMachineModel;
            mip.mom_cOperationName = operationModel.mom_cOperationName;
            mip.mom_cOperationTypeName = operationModel.mom_cOperationType;
            mip.mom_iCompleteTime = operationModel.mom_iCompleteTime;
            mip.IsActiveChiness = (MaintenanceInfoProprety.YesNo)Enum.Parse(typeof(MaintenanceInfoProprety.YesNo), operationModel.IsAtiveChiness);
            mip.mom_cStandardFilePath = operationModel.mom_cStandardFilePath;

            //(NO:0005078)  Add By Leothlink TonyWu On 07/18/2014  >>>
            if (operationModel.mom_iRecordID != 0)
            {
                _PlanEquipmentList = _maintainOperationMasterBL.GetPlanMaintainEquipments(operationModel.mom_iRecordID);
                ShowPlanEquipment();
            }
            //(NO:0005078)  Add By Leothlink TonyWu On 07/18/2014  <<<

            this.ppgMaintenanceInfo.SelectedObject = mip;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 保存保存部件清单
        /// </summary>
        /// <param name="p_objMOMInfo"></param>
        /// <param name="p_objMaintainInfo"></param>
        /// <param name="p_lisEquipments"></param>
        /// <returns></returns>
        /// <remarks>(NO:0005078) Add By Leothlink TonyWu On 07/18/2014</remarks>
        public static bool SaveMaintainEquipments(MaintainOperationMaster_mom_Info p_objMOMInfo, MaintainRecord_mtr_Info p_objMaintainInfo, List<MaintainEquipmentMapping_mem_Info> p_lisEquipments)
        {
            List<MaintainOperation> l_lisInsert = new List<MaintainOperation>();

            try
            {
                if (p_lisEquipments.Count > 0)
                {
                    foreach (var l_objEquipment in p_lisEquipments)
                    {
                        MaintainOperation l_objItem = new MaintainOperation()
                        {
                            AddBy = l_objEquipment.mem_cAddBy,
                            AddTime = DateTime.Now,
                            Duration = p_objMOMInfo.mom_iCompleteTime.ToString(),
                            EndTime = p_objMaintainInfo.mtr_dEndTime,
                            EquipNumber = l_objEquipment.mem_cEquipmentNum,
                            IsActive = true,
                            OperationCode = p_objMOMInfo.mom_cOperationCode,
                            OperationName = p_objMOMInfo.mom_cOperationName,
                            OperationType = p_objMOMInfo.mom_cOperationType,
                            ParentEquipNumber = l_objEquipment.mem_cPreEquipmentNum,
                            RecordId = l_objEquipment.mem_cRecordID,
                            StandardFile = p_objMOMInfo.mom_cStandardFilePath,
                            StartTime = p_objMaintainInfo.mtr_dBeginTime,
                            MtrId = p_objMaintainInfo.mtr_RecordID,
                            MtrPlanId = p_objMaintainInfo.mtr_iPlanID == null ? 0 : p_objMaintainInfo.mtr_iPlanID.Value
                        };

                        l_lisInsert.Add(l_objItem);
                    }
                }
                else
                {
                    MaintainOperation l_objItem = new MaintainOperation()
                    {
                        AddBy = "SYSTEM",
                        AddTime = DateTime.Now,
                        Duration = p_objMOMInfo.mom_iCompleteTime.ToString(),
                        EndTime = p_objMaintainInfo.mtr_dEndTime,
                        EquipNumber = "",
                        IsActive = true,
                        OperationCode = p_objMOMInfo.mom_cOperationCode,
                        OperationName = p_objMOMInfo.mom_cOperationName,
                        OperationType = p_objMOMInfo.mom_cOperationType,
                        ParentEquipNumber = "",
                        RecordId = Guid.Empty,
                        StandardFile = p_objMOMInfo.mom_cStandardFilePath,
                        StartTime = p_objMaintainInfo.mtr_dBeginTime,
                        MtrId = p_objMaintainInfo.mtr_RecordID,
                        MtrPlanId = p_objMaintainInfo.mtr_iPlanID == null ? 0 : p_objMaintainInfo.mtr_iPlanID.Value
                    };

                    l_lisInsert.Add(l_objItem);
                }

                _MaximoServiceWS.SaveMaintainList(p_objMaintainInfo.mtr_RecordID, l_lisInsert.ToArray());

                return true;
            }
            catch
            {
                return false;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 保養動作主檔
        /// </summary>
        public List<MaintainOperationMaster_mom_Info> GetMaintainOperationMaster(string machineType)
        {
            try
            {
                List<MaintainOperationMaster_mom_Info> list = new List<MaintainOperationMaster_mom_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select");
                strSql.AppendLine("mom_iRecordID,mom_cOperationCode,mom_cOperationName,mom_cOperationType,mom_cMachineModel,mom_lIsAtive,mom_iCompleteTime,mom_cStandardFilePath,mom_cAdd,mom_dAddDate,mom_cLast,mom_dLastDate ");
                strSql.AppendLine("from MaintainOperationMaster_mom ");
                strSql.AppendLine("where mom_cMachineModel='"+machineType.Trim()+"'");
                strSql.AppendLine("and mom_lIsAtive=1 ");

                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        MaintainOperationMaster_mom_Info model = new MaintainOperationMaster_mom_Info();
                        if (sdr["mom_iRecordID"] != null && sdr["mom_iRecordID"].ToString() != "")
                        {
                            model.mom_iRecordID = int.Parse(sdr["mom_iRecordID"].ToString());
                        }
                        if (sdr["mom_cOperationCode"] != null && sdr["mom_cOperationCode"].ToString() != "")
                        {
                            model.mom_cOperationCode = sdr["mom_cOperationCode"].ToString();
                        }
                        if (sdr["mom_cOperationName"] != null && sdr["mom_cOperationName"].ToString() != "")
                        {
                            model.mom_cOperationName = sdr["mom_cOperationName"].ToString();
                        }
                        if (sdr["mom_cOperationType"] != null && sdr["mom_cOperationType"].ToString() != "")
                        {
                            model.mom_cOperationType = sdr["mom_cOperationType"].ToString();
                        }
                        if (sdr["mom_cMachineModel"] != null && sdr["mom_cMachineModel"].ToString() != "")
                        {
                            model.mom_cMachineModel = sdr["mom_cMachineModel"].ToString();
                        }
                        if (sdr["mom_lIsAtive"] != null && sdr["mom_lIsAtive"].ToString() != "")
                        {
                            if ((sdr["mom_lIsAtive"].ToString() == "1") || (sdr["mom_lIsAtive"].ToString().ToLower() == "true"))
                            {
                                model.mom_lIsAtive = true;
                            }
                            else
                            {
                                model.mom_lIsAtive = false;
                            }
                        }
                        if (sdr["mom_iCompleteTime"] != null && sdr["mom_iCompleteTime"].ToString() != "")
                        {
                            model.mom_iCompleteTime = int.Parse(sdr["mom_iCompleteTime"].ToString());
                        }
                        if (sdr["mom_cStandardFilePath"] != null && sdr["mom_cStandardFilePath"].ToString() != "")
                        {
                            model.mom_cStandardFilePath = sdr["mom_cStandardFilePath"].ToString();
                        }
                        if (sdr["mom_cAdd"] != null && sdr["mom_cAdd"].ToString() != "")
                        {
                            model.mom_cAdd = sdr["mom_cAdd"].ToString();
                        }
                        if (sdr["mom_dAddDate"] != null && sdr["mom_dAddDate"].ToString() != "")
                        {
                            model.mom_dAddDate = DateTime.Parse(sdr["mom_dAddDate"].ToString());
                        }
                        if (sdr["mom_cLast"] != null && sdr["mom_cLast"].ToString() != "")
                        {
                            model.mom_cLast = sdr["mom_cLast"].ToString();
                        }
                        if (sdr["mom_dLastDate"] != null && sdr["mom_dLastDate"].ToString() != "")
                        {
                            model.mom_dLastDate = DateTime.Parse(sdr["mom_dLastDate"].ToString());
                        }
                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
        public List<MaintainOperationMaster_mom_Info> SearchRecords(Model.IModel.IModelObject searchCondition)
        {
            List<MaintainOperationMaster_mom_Info> list = new List<MaintainOperationMaster_mom_Info>();
            MaintainOperationMaster_mom_Info info = new MaintainOperationMaster_mom_Info();
            info = searchCondition as MaintainOperationMaster_mom_Info;

            StringBuilder sqlString = new StringBuilder();

            sqlString.AppendLine("SELECT TOP " + Common.DefineConstantValue.ListRecordMaxCount.ToString());
            sqlString.AppendLine("cmt_cRemark as mom_cOperationTypeName,*");
            sqlString.AppendLine("FROM MaintainOperationMaster_mom LEFT JOIN CodeMaster_cmt");

            sqlString.AppendLine("on cmt_cKey1='" + Common.DefineConstantValue.CodeMasterDefine.KEY1_TYPEVALUE + "' and cmt_cKey2='" + Common.DefineConstantValue.CodeMasterDefine.KEY2_MAINTENANCETYPE + "' and cmt_cValue=mom_cOperationType");

            sqlString.AppendLine("WHERE 1=1");

            if (info.mom_cOperationCode != "")
            {
                sqlString.AppendLine("AND mom_cOperationCode='" + info.mom_cOperationCode + "'");
            }

            if (info.mom_cMachineModel != "")
            {
                sqlString.AppendLine("AND mom_cMachineModel='" + info.mom_cMachineModel + "'");
            }

            if (info.mom_cOperationType != "")
            {
                sqlString.AppendLine("AND mom_cOperationType='" + info.mom_cOperationType + "'");
            }

            if (info.mom_cOperationName != "")
            {
                sqlString.AppendLine("AND mom_cOperationName='" + info.mom_cOperationName + "'");
            }

            IEnumerable<MaintainOperationMaster_mom_Info> infos = null;

            using (MainDBDataContext db = new MainDBDataContext())
            {
                infos = db.ExecuteQuery<MaintainOperationMaster_mom_Info>(sqlString.ToString(), new object[] { });

                if (infos != null)
                {
                    list = infos.ToList<MaintainOperationMaster_mom_Info>();
                }
            }

            return list;
        }
Exemplo n.º 8
0
        public bool InsertRecord(MaintainOperationMaster_mom_Info infoObject)
        {
            bool isSuccess = false;
            #region 舊代碼
            //MaintainOperationMaster_mom_Info info = new MaintainOperationMaster_mom_Info();
            //info = infoObject;

            //using (MainDBDataContext db = new MainDBDataContext())
            //{
            //    MaintainOperationMaster_mom newTab = Common.General.CopyObjectValue<MaintainOperationMaster_mom_Info, MaintainOperationMaster_mom>(infoObject);
            //    db.MaintainOperationMaster_mom.InsertOnSubmit(newTab);
            //    db.SubmitChanges();
            //    isSuccess = true;
            //}
            #endregion

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;

            if (infoObject != null)
            {

                try
                {
                    using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                    {
                        SqlTransaction transaction = null;
                        conn.Open(); //開啟連接
                        transaction = conn.BeginTransaction(); //開啟事務

                        strSql += "Insert into MaintainOperationMaster_mom" + Environment.NewLine;
                        strSql += "( mom_cOperationCode, mom_cOperationName, mom_cOperationType, mom_cMachineModel, mom_lIsAtive, mom_iCompleteTime, mom_cStandardFilePath, mom_cAdd, mom_dAddDate, mom_cLast, mom_dLastDate)" + Environment.NewLine;
                        strSql += "values" + Environment.NewLine;
                        strSql += "('" + infoObject.mom_cOperationCode + "','" + infoObject.mom_cOperationName + "','" + infoObject.mom_cOperationType + "','" + infoObject.mom_cMachineModel + "',1," + infoObject.mom_iCompleteTime + ",'" + infoObject.mom_cStandardFilePath + "','" + infoObject.mom_cAdd + "',getdate(),'" + infoObject.mom_cLast + "',getdate())" + Environment.NewLine;

                        try
                        {
                            isSuccess = ExecuteSQL(strSql, transaction);

                        }
                        catch (Exception Ex)
                        {
                            transaction.Rollback();
                            throw Ex;
                        }
                        finally
                        {
                            if (isSuccess)
                                transaction.Commit();
                        }
                    }
                }
                catch (Exception Ex)
                {

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

            return isSuccess;
        }
Exemplo n.º 9
0
        public MaintainOperationMaster_mom_Info GetRecord_Previous(Model.Base.DataBaseCommandInfo commandInfo)
        {
            MaintainOperationMaster_mom_Info info = new MaintainOperationMaster_mom_Info(); ;

            #region 舊代碼
            //using (MainDBDataContext db = new MainDBDataContext())
            //{
            //    MaintainOperationMaster_mom query = db.MaintainOperationMaster_mom
            //    .Where(t => t.mom_iRecordID < Convert.ToInt32(commandInfo.KeyInfoList[0].KeyValue))
            //    .OrderByDescending(t => t.mom_iRecordID)
            //    .FirstOrDefault();
            //    info = Common.General.CopyObjectValue<MaintainOperationMaster_mom, MaintainOperationMaster_mom_Info>(query);
            //}
            #endregion

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;
            strSql += "select top 1 * " + Environment.NewLine;
            strSql += "from MaintainOperationMaster_mom NOLOCK" + Environment.NewLine;
            strSql += "where mom_iRecordID < " + Convert.ToInt32(commandInfo.KeyInfoList[0].KeyValue) + Environment.NewLine;
            strSql += "order by mom_iRecordID desc" + Environment.NewLine;

            try
            {
                using (SqlDataReader reader = DbHelperSQL.ExecuteReader(strSql))
                {
                    while (reader.Read())
                    {

                        #region 實體賦值
                        if (reader["mom_iRecordID"] != null && reader["mom_iRecordID"].ToString() != string.Empty)
                        {
                            info.mom_iRecordID = Convert.ToInt32(reader["mom_iRecordID"].ToString());
                        }

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

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

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

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

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

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

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

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

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

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

                        if (reader["mom_dLastDate"] != null && reader["mom_dLastDate"].ToString() != string.Empty)
                        {
                            info.mom_dLastDate = Convert.ToDateTime(reader["mom_dLastDate"].ToString());
                        }
                        #endregion
                        break;
                    }
                }
            }
            catch (Exception Ex)
            {

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

            return info;
        }
Exemplo n.º 10
0
 public List<MaintainOperationMaster_mom_Info> FindRecord(MaintainOperationMaster_mom_Info info)
 {
     return SearchRecords(info);
 }
Exemplo n.º 11
0
        public MaintainOperationMaster_mom_Info DisplayRecord(Model.IModel.IModelObject KeyObject)
        {
            MaintainOperationMaster_mom_Info info = new MaintainOperationMaster_mom_Info();

            #region 舊代碼
            //using (MainDBDataContext db = new MainDBDataContext())
            //{
            //    MaintainOperationMaster_mom disTab = db.MaintainOperationMaster_mom.SingleOrDefault(t => t.mom_iRecordID == ((KeyObject) as MaintainOperationMaster_mom_Info).mom_iRecordID);
            //    if (disTab != null)
            //    {
            //        info = Common.General.CopyObjectValue<MaintainOperationMaster_mom, MaintainOperationMaster_mom_Info>(disTab);
            //    }
            //}
            #endregion

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;

            if (KeyObject != null)
            {
                strSql += "select * from MaintainOperationMaster_mom NOLOCK" + Environment.NewLine;
                strSql += "where mom_iRecordID=" + ((KeyObject) as MaintainOperationMaster_mom_Info).mom_iRecordID + Environment.NewLine;
                try
                {
                    using (SqlDataReader reader = DbHelperSQL.ExecuteReader(strSql))
                    {
                        while (reader.Read())
                        {
                            #region 實體賦值
                            if (reader["mom_iRecordID"] != null && reader["mom_iRecordID"].ToString() != string.Empty)
                            {
                                info.mom_iRecordID = Convert.ToInt32(reader["mom_iRecordID"].ToString());
                            }

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

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

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

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

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

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

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

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

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

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

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

                            break;
                        }
                    }
                }
                catch (Exception Ex)
                {

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

            return info;
        }
Exemplo n.º 12
0
        public bool UpdateRecord(MaintainOperationMaster_mom_Info infoObject)
        {
            bool isSuccess = false;

            #region 舊代碼
            //using (MainDBDataContext db = new MainDBDataContext())
            //{

            //    MaintainOperationMaster_mom query = db.MaintainOperationMaster_mom.SingleOrDefault(t => t.mom_iRecordID == infoObject.mom_iRecordID);
            //    if (query != null)
            //    {
            //        query.mom_cOperationName = infoObject.mom_cOperationName;
            //        query.mom_cOperationType = infoObject.mom_cOperationType;
            //        query.mom_cMachineModel = infoObject.mom_cMachineModel;

            //        query.mom_cStandardFilePath = infoObject.mom_cStandardFilePath;

            //        //*(No: )Modify By Leothlink Sunwind Lee (Date:2013/03/06)*/lIsDeleted改為lIsAtive
            //        //query.mom_lIsDeleted = infoObject.mom_lIsDeleted;
            //        query.mom_lIsAtive = infoObject.mom_lIsAtive;
            //        //*(No: )End Modify By Leothlink Sunwind Lee (Date:2013/03/06)*/lIsDeleted改為lIsAtive
            //        query.mom_iCompleteTime = infoObject.mom_iCompleteTime;
            //        query.mom_cLast = infoObject.mom_cLast;
            //        query.mom_dLastDate = infoObject.mom_dLastDate;
            //        db.SubmitChanges();
            //        isSuccess = true;
            //    }
            //}
            #endregion

            //Add By Ximonliang 2015-03-09------------------------>>
            string strSql = string.Empty;

            if (infoObject != null)
            {

                try
                {
                    using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
                    {
                        SqlTransaction transaction = null;
                        conn.Open(); //開啟連接
                        transaction = conn.BeginTransaction(); //開啟事務

                        strSql += "update  MaintainOperationMaster_mom" + Environment.NewLine;
                        strSql += "set mom_cOperationName='" + infoObject.mom_cOperationName + "'" + Environment.NewLine;
                        strSql += ",mom_cOperationType='" + infoObject.mom_cOperationType + "'" + Environment.NewLine;
                        strSql += ",mom_cMachineModel='" + infoObject.mom_cMachineModel + "'" + Environment.NewLine;
                        strSql += ",mom_cStandardFilePath='" + infoObject.mom_cStandardFilePath + "'" + Environment.NewLine;
                        strSql += ",mom_lIsAtive=" + (infoObject.mom_lIsAtive == true ? "1" : "0") + Environment.NewLine;
                        strSql += ",mom_iCompleteTime=" + infoObject.mom_iCompleteTime + Environment.NewLine;
                        strSql += ",mom_cLast='" + infoObject.mom_cLast + "'" + Environment.NewLine;
                        strSql += ",mom_dLastDate=getdate()" + Environment.NewLine;
                        strSql += "where mom_iRecordID=" + infoObject.mom_iRecordID + Environment.NewLine;

                        try
                        {
                            isSuccess = ExecuteSQL(strSql, transaction);
                        }
                        catch (Exception Ex)
                        {
                            transaction.Rollback();
                            throw Ex;
                        }
                        finally
                        {
                            if (isSuccess)
                                transaction.Commit();
                        }

                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
            //Add By Ximonliang 2015-03-09------------------------<<

            return isSuccess;
        }
Exemplo n.º 13
0
 private string GetMaintainOperationMasterSQL(MaintainOperationMaster_mom_Info model)
 {
     StringBuilder strSql = new StringBuilder();
     StringBuilder strSql1 = new StringBuilder();
     StringBuilder strSql2 = new StringBuilder();
     if (model.mom_iRecordID != null)
     {
         strSql1.Append("mom_iRecordID,");
         strSql2.Append("" + model.mom_iRecordID + ",");
     }
     if (model.mom_cOperationCode != null)
     {
         strSql1.Append("mom_cOperationCode,");
         strSql2.Append("'" + model.mom_cOperationCode + "',");
     }
     if (model.mom_cOperationName != null)
     {
         strSql1.Append("mom_cOperationName,");
         strSql2.Append("'" + model.mom_cOperationName + "',");
     }
     if (model.mom_cOperationType != null)
     {
         strSql1.Append("mom_cOperationType,");
         strSql2.Append("'" + model.mom_cOperationType + "',");
     }
     if (model.mom_cMachineModel != null)
     {
         strSql1.Append("mom_cMachineModel,");
         strSql2.Append("'" + model.mom_cMachineModel + "',");
     }
     if (model.mom_lIsAtive != null)
     {
         strSql1.Append("mom_lIsAtive,");
         strSql2.Append("" + (model.mom_lIsAtive ? 1 : 0) + ",");
     }
     if (model.mom_cStandardFilePath != null)
     {
         strSql1.Append("mom_cStandardFilePath,");
         strSql2.Append("'" + model.mom_cStandardFilePath + "',");
     }
     if (model.mom_iCompleteTime != null)
     {
         strSql1.Append("mom_iCompleteTime,");
         strSql2.Append("" + model.mom_iCompleteTime + ",");
     }
     if (model.mom_cAdd != null)
     {
         strSql1.Append("mom_cAdd,");
         strSql2.Append("'" + model.mom_cAdd + "',");
     }
     if (model.mom_dAddDate != null)
     {
         strSql1.Append("mom_dAddDate,");
         strSql2.Append("'" + model.mom_dAddDate.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     if (model.mom_cLast != null)
     {
         strSql1.Append("mom_cLast,");
         strSql2.Append("'" + model.mom_cLast + "',");
     }
     if (model.mom_dLastDate != null)
     {
         strSql1.Append("mom_dLastDate,");
         strSql2.Append("'" + model.mom_dLastDate.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     strSql.Append("insert into MaintainOperationMaster_mom(");
     strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
     strSql.Append(")");
     strSql.Append(" values (");
     strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
     strSql.Append(")");
     return strSql.ToString();
 }