Exemple #1
0
        private void SaveByReason()
        {
            bool retValue = true;

            List<MachineStopReasonProfile_msrp_Info> data = new List<MachineStopReasonProfile_msrp_Info>();
            foreach (ListViewItem item in lvSelectedMachines2.Items)
            {

                MachineMaster_mmt_Info mmt = item.Tag as MachineMaster_mmt_Info;

                MachineStopReasonProfile_msrp_Info obj;

                obj = new MachineStopReasonProfile_msrp_Info();
                obj.msrp_cMachineID = mmt.mmt_cMachineID;
                obj.msrp_iSRPFID = mSelectedReasonID;
                obj.msrp_lIsDeleted = false;
                obj.msrp_dUpdateTime = DateTime.Now;
                data.Add(obj);
            }

            retValue = _MachineStopReasonBL.SavePPByReasonID(mSelectedReasonID, data);

            if (retValue)
            {
                m_MachineStopReasonProfile = _MachineStopReasonBL.GetStopReasonByReasonID(mSelectedReasonID);
                MessageBox.Show("保存成功!");
                tsbAdd.Enabled = false;
            }
            else
            {
                MessageBox.Show("保存失敗,請重新選擇!");
            }
            ClearData();
        }
Exemple #2
0
        /// <summary>
        /// 停機原因主檔
        /// </summary>
        public List<MachineStopReasonProfile_msrp_Info> GetMachineStopReasonMapping(string machineID)
        {
            try
            {
                List<MachineStopReasonProfile_msrp_Info> list = new List<MachineStopReasonProfile_msrp_Info>();
                StringBuilder strSql = new StringBuilder();
                strSql.AppendLine("select");
                strSql.AppendLine("msrp_iMSRPID,msrp_iSRPFID,msrp_cMachineID,msrp_lIsDeleted,msrp_dUpdateTime ");
                strSql.AppendLine("from MachineStopReasonProfile_msrp ");
                strSql.AppendLine("where msrp_cMachineID='"+machineID.Trim()+"' ");
                strSql.AppendLine("and msrp_lIsDeleted=0");

                using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
                {
                    while (sdr.Read())
                    {
                        MachineStopReasonProfile_msrp_Info model = new MachineStopReasonProfile_msrp_Info();
                        if (sdr["msrp_iMSRPID"] != null && sdr["msrp_iMSRPID"].ToString() != "")
                        {
                            model.msrp_iMSRPID = int.Parse(sdr["msrp_iMSRPID"].ToString());
                        }
                        if (sdr["msrp_iSRPFID"] != null && sdr["msrp_iSRPFID"].ToString() != "")
                        {
                            model.msrp_iSRPFID = int.Parse(sdr["msrp_iSRPFID"].ToString());
                        }
                        if (sdr["msrp_cMachineID"] != null && sdr["msrp_cMachineID"].ToString() != "")
                        {
                            model.msrp_cMachineID = sdr["msrp_cMachineID"].ToString();
                        }
                        if (sdr["msrp_lIsDeleted"] != null && sdr["msrp_lIsDeleted"].ToString() != "")
                        {
                            if ((sdr["msrp_lIsDeleted"].ToString() == "1") || (sdr["msrp_lIsDeleted"].ToString().ToLower() == "true"))
                            {
                                model.msrp_lIsDeleted = true;
                            }
                            else
                            {
                                model.msrp_lIsDeleted = false;
                            }
                        }
                        if (sdr["msrp_dUpdateTime"] != null && sdr["msrp_dUpdateTime"].ToString() != "")
                        {
                            model.msrp_dUpdateTime = DateTime.Parse(sdr["msrp_dUpdateTime"].ToString());
                        }
                        list.Add(model);
                    }
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public bool UpdateRecord(MachineStopReasonProfile_msrp_Info infoObject)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
        private IList<MachineStopReasonProfile_msrp_Info> CreateMachineStopReasonProfileFromStopReasonData(IList<StopReasonMaster_srm_Info> data)
        {
            MachineMaster_mmt_Info dcm = GetDCMProfile();
            if (dcm == null)
            {
                MessageBox.Show(" 請選擇幾台!"); return null;
            }
            IList<MachineStopReasonProfile_msrp_Info> msrpData = new List<MachineStopReasonProfile_msrp_Info>();
            foreach (StopReasonMaster_srm_Info item in data)
            {
                MachineStopReasonProfile_msrp_Info obj;
                obj = m_MachineStopReasonProfile.Find(f => f.msrp_iSRPFID == item.srm_iRecordID);
                if (obj == null)
                    obj = m_MachineStopReasonProfileInsertData.Find(f => f.msrp_iSRPFID == item.srm_iRecordID);

                if (obj == null)
                {
                    obj = new MachineStopReasonProfile_msrp_Info();
                    obj.msrp_iSRPFID = item.srm_iRecordID;
                    obj.msrp_cMachineID = dcm.mmt_cMachineID;
                    obj.msrp_lIsDeleted = false;
                    //obj.OID = commManager.GetMaxID(typeof(MachineStopReasonProfile).Name);
                    //obj.MSRPID = obj.OID;
                    //obj.SRPFID = item.SRPFID;
                    //obj.DCMPID = dcm.DCMPID;
                }

                obj.msrp_dUpdateTime = DateTime.Now;
                msrpData.Add(obj);
            }
            return msrpData;
        }
 public bool InsertRecord(MachineStopReasonProfile_msrp_Info infoObject)
 {
     //throw new NotImplementedException();
     bool isSuccess = false;
     try
     {
         using (MainDBDataContext db = new MainDBDataContext())
         {
             MachineStopReasonProfile_msrp newTab = Common.General.CopyObjectValue<MachineStopReasonProfile_msrp_Info, MachineStopReasonProfile_msrp>(infoObject);
             db.MachineStopReasonProfile_msrp.InsertOnSubmit(newTab);
             db.SubmitChanges();
             isSuccess = true;
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     return isSuccess;
 }
Exemple #6
0
 private string GetMachineStopReasonMappingSQL(MachineStopReasonProfile_msrp_Info model)
 {
     StringBuilder strSql = new StringBuilder();
     StringBuilder strSql1 = new StringBuilder();
     StringBuilder strSql2 = new StringBuilder();
     if (model.msrp_iMSRPID != null)
     {
         strSql1.Append("msrp_iMSRPID,");
         strSql2.Append("'" + model.msrp_iMSRPID + "',");
     }
     if (model.msrp_iSRPFID != null)
     {
         strSql1.Append("msrp_iSRPFID,");
         strSql2.Append("" + model.msrp_iSRPFID + ",");
     }
     if (model.msrp_cMachineID != null)
     {
         strSql1.Append("msrp_cMachineID,");
         strSql2.Append("'" + model.msrp_cMachineID + "',");
     }
     if (model.msrp_lIsDeleted != null)
     {
         strSql1.Append("msrp_lIsDeleted,");
         strSql2.Append("" + (model.msrp_lIsDeleted ? 1 : 0) + ",");
     }
     if (model.msrp_dUpdateTime != null)
     {
         strSql1.Append("msrp_dUpdateTime,");
         strSql2.Append("'" + model.msrp_dUpdateTime.ToString(this._sqlLiteDatetimeFormat) + "',");
     }
     strSql.Append("insert into MachineStopReasonProfile_msrp(");
     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();
 }
        public bool SavePPByReasonID(int  ReasonID, List<MachineStopReasonProfile_msrp_Info> MCList)
        {
            //throw new NotImplementedException();
            //throw new NotImplementedException();

            bool returnValue = true;

            if (MCList == null) return true;

            if (ReasonID == 0) return true;
            try
            {

                _MachineStopReasonDA.DeleteListByReasonID(ReasonID);

                //List<MachinePrepareItem_mpit_Info> hadSelet = _MachineReadyPlanDA.GetPrepareProjectsByMachine(Machine);

                foreach (MachineStopReasonProfile_msrp_Info item in MCList)
                {
                    MachineStopReasonProfile_msrp_Info insertItem = new MachineStopReasonProfile_msrp_Info();
                    insertItem.msrp_iSRPFID  = ReasonID ;
                    insertItem.msrp_cMachineID = item.msrp_cMachineID ;
                    insertItem.msrp_lIsDeleted = false;
                    insertItem.msrp_dUpdateTime = DateTime.Now;
                    //insertItem.mpit_MPITID = Guid.NewGuid();

                    returnValue = _MachineStopReasonDA.InsertRecord(insertItem);

                }

            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return returnValue;
        }
        public bool SaveMachineStopReasonByMachie(string MachineID, List<MachineStopReasonProfile_msrp_Info> ReasonList)
        {
            //throw new NotImplementedException();
            bool returnValue = true;

            if (ReasonList == null) return true;

            if (MachineID.Trim().Length == 0) return true;
            try
            {

                _MachineStopReasonDA.DeleteListByMachie(MachineID);

                //List<MachineStopReasonProfile_msrp_Info> hadSelet = _MachineStopReasonDA.GetPrepareProjectsByMachine(Machine);

                foreach (MachineStopReasonProfile_msrp_Info item in ReasonList)
                {
                    MachineStopReasonProfile_msrp_Info insertItem = new MachineStopReasonProfile_msrp_Info();
                    insertItem.msrp_cMachineID  = MachineID ;
                    insertItem.msrp_iSRPFID  = item.msrp_iSRPFID ;
                    insertItem.msrp_lIsDeleted  = false;
                    insertItem.msrp_dUpdateTime  = DateTime.Now;
                    //insertItem.msrp_iMSRPID = -1;

                    returnValue = _MachineStopReasonDA.InsertRecord(insertItem);

                }

            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return returnValue;
        }
        public Model.General.ReturnValueInfo Save(Model.IModel.IModelObject itemEntity, Common.DefineConstantValue.EditStateEnum EditMode)
        {
            Model.General.ReturnValueInfo returnValue = new Model.General.ReturnValueInfo();
            MachineStopReasonProfile_msrp_Info info = new MachineStopReasonProfile_msrp_Info();
            returnValue.messageText = "";
            info = itemEntity as MachineStopReasonProfile_msrp_Info;
            try
            {
                switch (EditMode)
                {
                    case Common.DefineConstantValue.EditStateEnum.OE_Insert:
                        bool isExist = false;

                        //info.mpit_MPITID = Guid.NewGuid();
                        returnValue.boolValue = _MachineStopReasonDA.InsertRecord(info);

                        //isExist = _MachineStopReasonDA.IsExistRecord(info);
                        //if (!isExist)
                        //{
                        //    returnValue.boolValue = _MachineStopReasonDA.InsertRecord(info);
                        //}
                        //else
                        //{
                        //    returnValue.boolValue = false;
                        //    returnValue.messageText = "數據重複!";
                        //}
                        break;
                    case Common.DefineConstantValue.EditStateEnum.OE_Update:
                        returnValue.boolValue = _MachineStopReasonDA.UpdateRecord(info);
                        break;
                    case Common.DefineConstantValue.EditStateEnum.OE_Delete:
                        returnValue.boolValue = _MachineStopReasonDA.DeleteRecord(info);
                        break;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return returnValue;
        }