Beispiel #1
0
        /// <summary>
        /// Get instrument name of given instrument code.
        /// </summary>
        /// <param name="InstrumentCode"></param>
        /// <returns></returns>
        public ActionResult IVS160_GetInstrumentName(string InstrumentCode)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IInstrumentMasterHandler hand = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler;
                List <tbm_Instrument>    list = hand.GetTbm_Instrument(InstrumentCode);
                tbm_Instrument           item = new tbm_Instrument();
                if (list.Count > 0)
                {
                    res.ResultData = new IVS160_InstrumetInfo()
                    {
                        InstrumentCode = list[0].InstrumentCode,
                        InstrumentName = list[0].InstrumentName
                    };
                }
                else
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4037);
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #2
0
        public ActionResult MAS090_InsertInstrument(MAS090_SaveInstrument instrument)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                #region Check system suspending

                res = checkSystemSuspending();
                if (res.IsError)
                {
                    return(Json(res));
                }

                #endregion

                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

                #region Validate require field

                ValidatorUtil validator = new ValidatorUtil(this);
                if (!instrument.SaleFlag.HasValue)
                {
                    instrument.SaleFlag = false;
                }
                if (!instrument.RentalFlag.HasValue)
                {
                    instrument.RentalFlag = false;
                }
                if (!instrument.InstrumentFlag.HasValue)
                {
                    instrument.InstrumentFlag = false;
                }
                if (!instrument.ZeroBahtAssetFlag.HasValue)
                {
                    instrument.ZeroBahtAssetFlag = false;
                }
                if (!instrument.MaintenanceFlag.HasValue)
                {
                    instrument.MaintenanceFlag = false;
                }
                if (!instrument.ControllerFlag.HasValue)
                {
                    instrument.ControllerFlag = false;
                }

                if (InstrumentType.C_INST_TYPE_GENERAL.Equals(instrument.InstrumentTypeCode))
                {
                    if (instrument.LineUpTypeCode == null)
                    {
                        validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                  MAS090_Screen,
                                                  MessageUtil.MODULE_COMMON,
                                                  MessageUtil.MessageList.MSG0007,
                                                  "RLineUpTypeCode",
                                                  "lblLineUpType",
                                                  "LineUpTypeCode");
                    }
                    if (instrument.ExpansionTypeCode == null)
                    {
                        validator.AddErrorMessage(MessageUtil.MODULE_MASTER,
                                                  MAS090_Screen,
                                                  MessageUtil.MODULE_COMMON,
                                                  MessageUtil.MessageList.MSG0007,
                                                  "RExpansionTypeCode",
                                                  "lblExpansionType",
                                                  "ExpansionTypeCode");
                    }
                }

                ValidatorUtil.BuildErrorMessage(res, validator);
                if (res.IsError)
                {
                    return(Json(res));
                }

                #endregion
                #region Check duplicate instrument information

                IInstrumentMasterHandler hand      = ServiceContainer.GetService <IInstrumentMasterHandler>() as IInstrumentMasterHandler;
                List <bool?>             listCheck = hand.CheckExistInstrument(instrument.InstrumentCode);
                if (listCheck.Count != 0 && listCheck[0].Value)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1019);
                    return(Json(res));
                }

                #endregion



                // add by Jirawat Jannet on 216-12-23
                #region Set amount and currency type

                if (instrument.SaleUnitPriceCurrencyType == CurrencyUtil.C_CURRENCY_US)
                {
                    instrument.SaleUnitPriceUsd = instrument.SaleUnitPrice;
                    instrument.SaleUnitPrice    = null;
                }
                else
                {
                    instrument.SaleUnitPriceUsd = null;
                }

                if (instrument.RentalUnitPriceCurrencyType == CurrencyUtil.C_CURRENCY_US)
                {
                    instrument.RentalUnitPriceUsd = instrument.RentalUnitPrice;
                    instrument.RentalUnitPrice    = null;
                }
                else
                {
                    instrument.RentalUnitPriceUsd = null;
                }

                if (instrument.AddUnitPriceCurrencyType == CurrencyUtil.C_CURRENCY_US)
                {
                    instrument.AddUnitPriceUsd = instrument.AddUnitPrice;
                    instrument.AddUnitPrice    = null;
                }
                else
                {
                    instrument.AddUnitPriceUsd = null;
                }

                if (instrument.RemoveUnitPriceCurrencyType == CurrencyUtil.C_CURRENCY_US)
                {
                    instrument.RemoveUnitPriceUsd = instrument.RemoveUnitPrice;
                    instrument.RemoveUnitPrice    = null;
                }
                else
                {
                    instrument.RemoveUnitPriceUsd = null;
                }

                if (instrument.MoveUnitPriceCurrencyType == CurrencyUtil.C_CURRENCY_US)
                {
                    instrument.MoveUnitPriceUsd = instrument.MoveUnitPrice;
                    instrument.MoveUnitPrice    = null;
                }
                else
                {
                    instrument.MoveUnitPriceUsd = null;
                }

                #endregion
                #region Insert instrument data

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

                tbm_Instrument        inserted     = null;
                List <tbm_Instrument> listInserted = hand.InsertInstrument(instrument);
                if (listInserted.Count > 0)
                {
                    inserted = listInserted[0];
                }

                res.ResultData = inserted;

                #endregion
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }