public List <tbm_Instrument> InsertInstrument(tbm_Instrument instrument)
        {
            //Add by Jutarat A. on 14082013
            if (String.IsNullOrEmpty(instrument.InstrumentCode) == false)
            {
                instrument.InstrumentCode = instrument.InstrumentCode.Trim();
            }
            //End Add

            List <tbm_Instrument> insertList = new List <tbm_Instrument>();

            insertList.Add(instrument);
            string xml = CommonUtil.ConvertToXml_Store(insertList);
            List <tbm_Instrument> listInserted = base.InsertInstrument(xml);

            if (insertList == null || insertList.Count == 0)
            {
                return(null);
            }
            else
            {
                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Insert,
                    TableName       = TableName.C_TBL_NAME_INSTRUMENT,
                    TableData       = CommonUtil.ConvertToXml(insertList)
                };
                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteTransactionLog(logData);
            }

            return(insertList);
        }
Пример #2
0
            public void SetInstrumentData(tbm_Instrument inst)
            {
                if (inst == null ||
                    InstrumentProperty == null ||
                    InstrumentObject == null)
                {
                    return;
                }

                foreach (PropertyInfo prop in InstrumentProperty)
                {
                    PropertyInfo ipop = inst.GetType().GetProperty(prop.Name);
                    if (ipop != null)
                    {
                        prop.SetValue(InstrumentObject, ipop.GetValue(inst, null), null);
                    }
                }
            }
Пример #3
0
        private void Fixuptbm_Instrument(tbm_Instrument previousValue)
        {
            if (previousValue != null && previousValue.tbm_ProductFacility.Contains(this))
            {
                previousValue.tbm_ProductFacility.Remove(this);
            }

            if (tbm_Instrument != null)
            {
                if (!tbm_Instrument.tbm_ProductFacility.Contains(this))
                {
                    tbm_Instrument.tbm_ProductFacility.Add(this);
                }
                if (FacilityCode != tbm_Instrument.InstrumentCode)
                {
                    FacilityCode = tbm_Instrument.InstrumentCode;
                }
            }
        }
        public List <tbm_Instrument> UpdateInstrument(tbm_Instrument instrument)
        {
            List <DateTime?> updateDateList = base.GetInstrumentUpdateDate(instrument.InstrumentCode);

            if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                instrument.UpdateDate == null || !instrument.UpdateDate.HasValue)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            }
            if (updateDateList[0].Value.CompareTo(instrument.UpdateDate.Value) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { instrument.InstrumentCode });
            }

            instrument.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
            instrument.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;

            //8.5	Update instrument data
            List <tbm_Instrument> updateList = new List <tbm_Instrument>();

            updateList.Add(instrument);
            string xml = CommonUtil.ConvertToXml_Store(updateList);
            List <tbm_Instrument> listUpdated = base.UpdateInstrument(xml);

            if (listUpdated == null || listUpdated.Count == 0)
            {
                return(null);
            }
            else
            {
                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Update,
                    TableName       = TableName.C_TBL_NAME_INSTRUMENT,
                    TableData       = CommonUtil.ConvertToXml(listUpdated)
                };
                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteTransactionLog(logData);
            }

            return(listUpdated);
        }
Пример #5
0
        public List <tbm_Instrument> GetInstrumentList()
        {
            try
            {
                List <tbm_Instrument> instLst = new List <tbm_Instrument>();
                if (InstrumentList != null)
                {
                    foreach (InstrumentMappingData instData in InstrumentList)
                    {
                        tbm_Instrument inst = null;
                        foreach (tbm_Instrument i in instLst)
                        {
                            if (i.InstrumentCode == instData.InstrumentCode)
                            {
                                inst = i;
                                break;
                            }
                        }
                        if (inst == null)
                        {
                            inst = new tbm_Instrument()
                            {
                                InstrumentCode = instData.InstrumentCode
                            };
                            instLst.Add(inst);
                        }
                    }
                }

                return(instLst);
            }
            catch (Exception)
            {
                throw;
            }
        }