public static DataTypeView MapEntityToView(DataType dt)
        {
            DataTypeView dtv = new DataTypeView();

            dtv.FldKey           = dt.FldKey;
            dtv.FldBigInt        = dt.FldBigInt.ToString();
            dtv.FldBit           = dt.FldBit.ToString();
            dtv.FldChar          = dt.FldChar.Trim();
            dtv.FldDateTime      = dt.FldDateTime.ToString();
            dtv.FldDecimal       = dt.FldDecimal.ToString();
            dtv.FldInt           = dt.FldInt.ToString();
            dtv.FldMoney         = dt.FldMoney.ToString();
            dtv.FldNChar         = dt.FldNChar.Trim();
            dtv.FldNText         = dt.FldNText.Trim();
            dtv.FldNumeric       = dt.FldNumeric.ToString();
            dtv.FldNVarChar      = dt.FldNVarChar.Trim();
            dtv.FldNVarCharMax   = dt.FldNVarCharMax.Trim();
            dtv.FldSmallDateTime = dt.FldSmallDateTime.ToString();
            dtv.FldSmallInt      = dt.FldSmallInt.ToString();
            dtv.FldSmallMoney    = dt.FldSmallMoney.ToString();
            dtv.FldText          = dt.FldText.Trim();
            dtv.FldTinyInt       = dt.FldTinyInt.ToString();
            dtv.FldVarChar       = dt.FldVarChar.Trim();
            dtv.FldVarCharMax    = dt.FldVarCharMax.Trim();

            return(dtv);
        }
        public static DataType MapViewToEntity(DataTypeView dtv)
        {
            DataType dt = new DataType();

            dt.FldKey           = dtv.FldKey;
            dt.FldBigInt        = Convert.ToInt64(dtv.FldBigInt);
            dt.FldBit           = Boolean.Parse(dtv.FldBit);
            dt.FldChar          = dtv.FldChar;
            dt.FldDateTime      = Convert.ToDateTime(dtv.FldDateTime);
            dt.FldDecimal       = Convert.ToDecimal(dtv.FldDecimal);
            dt.FldInt           = Convert.ToInt32(dtv.FldInt);
            dt.FldMoney         = Convert.ToDecimal(dtv.FldMoney);
            dt.FldNChar         = dtv.FldNChar;
            dt.FldNText         = dtv.FldNText;
            dt.FldNumeric       = Convert.ToDecimal(dtv.FldNumeric);
            dt.FldNVarChar      = dtv.FldNVarChar;
            dt.FldNVarCharMax   = dtv.FldNVarCharMax;
            dt.FldSmallDateTime = Convert.ToDateTime(dtv.FldSmallDateTime);
            dt.FldSmallInt      = Convert.ToInt16(dtv.FldSmallInt);
            dt.FldSmallMoney    = Convert.ToDecimal(dtv.FldSmallMoney);
            dt.FldText          = dtv.FldText;
            dt.FldTinyInt       = Convert.ToByte(dtv.FldTinyInt);
            dt.FldVarChar       = dtv.FldVarChar;
            dt.FldVarCharMax    = dtv.FldVarCharMax;

            return(dt);
        }
Example #3
0
 private void AddViewToList(DataTypeView dtv, ref DataTypeList list)
 {
     // Map DataTypeView to DataType and add to DataTypeList
     list.Add(new DataType()
     {
         FldKey           = dtv.FldKey,
         FldBigInt        = dtv.FldBigInt.Trim(),
         FldBit           = dtv.FldBit.Trim(),
         FldChar          = dtv.FldChar.Trim(),
         FldDateTime      = dtv.FldDateTime.Trim(),
         FldDecimal       = dtv.FldDecimal.Trim(),
         FldInt           = dtv.FldInt.Trim(),
         FldMoney         = dtv.FldMoney.Trim(),
         FldNChar         = dtv.FldNChar.Trim(),
         FldNText         = dtv.FldNText.Trim(),
         FldNumeric       = dtv.FldNumeric.Trim(),
         FldNVarChar      = dtv.FldNVarChar.Trim(),
         FldNVarCharMax   = dtv.FldNVarCharMax.Trim(),
         FldSmallDateTime = dtv.FldSmallDateTime.Trim(),
         FldSmallInt      = dtv.FldSmallInt.Trim(),
         FldSmallMoney    = dtv.FldSmallMoney.Trim(),
         FldText          = dtv.FldText.Trim(),
         FldTinyInt       = dtv.FldTinyInt.Trim(),
         FldVarChar       = dtv.FldVarChar.Trim(),
         FldVarCharMax    = dtv.FldVarCharMax.Trim()
     });
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="dtv"></param>
        /// <returns></returns>
        public int SaveDataType(DataTypeView dtv)
        {
            int result = 0;

            // Validation
            this.Errors.Clear();

            try
            {
                // Data access
                if (!this.HasErrors)
                {
                    // Save
                    DataType entity = DataTypesMapper.MapViewToEntity(dtv);
                    result = this._repository.SetDataType(entity);
                }
            }
            catch (System.Data.UpdateException ex)
            {
                if (ex.InnerException != null && ex.InnerException is System.Data.SqlClient.SqlException &&
                    ((System.Data.SqlClient.SqlException)ex.InnerException).ErrorCode == 8152)
                {
                    Errors.Add(ResourceStrings.ErrorMaxLength);
                }
                else
                {
                    Errors.Add(ex.Message);
                }
            }

            return(result);
        }
Example #5
0
        public DataTypeList GetDataType(string FldKey)
        {
            DataTypeView dtv          = _dataTypesService.GetDataTypeView(int.Parse(FldKey));
            DataTypeList dataTypeList = new DataTypeList();

            AddViewToList(dtv, ref dataTypeList);
            return(dataTypeList);
        }
Example #6
0
        private static void GetDataTypeView(int FldKey)
        {
            DataTypeView dtv = null;

            dtv = dts.GetDataTypeView(FldKey);
            Console.WriteLine(string.Format("*** GetDataTypeView ***"));
            Console.WriteLine(string.Format("DataTypeView FldKey: {0}  FldNVarChar: {1}  FldNVarChar: {2}", dtv.FldKey.ToString(), dtv.FldNVarChar, dtv.FldBigInt.ToString()));
            Console.WriteLine(Environment.NewLine);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="FldKey"></param>
        /// <returns></returns>
        public DataTypeView GetDataTypeView(int FldKey)
        {
            DataTypeView dataTypeView = new DataTypeView();

            DataType dataType = _repository.GetDataType(FldKey);

            dataTypeView = DataTypesMapper.MapEntityToView(dataType);

            return(dataTypeView);
        }
        public JsonObject GetDataTypeSaveView(long dataTypeId, long pageNo, long itemsPerPage, long dataIndex, string templateSuffix)
        {
            JsonObject retMessage = new JsonObject();

            string htmlText = DataTypeView.GetSaveDetailView(dataTypeId, pageNo, itemsPerPage, dataIndex, templateSuffix);

            retMessage.Put("html", htmlText);

            return(retMessage);
        }
Example #9
0
        private static void UpdateDataTypeRow(int FldKey)
        {
            // Get DataTypeView
            DataTypeView dtv = null;

            dtv = dts.GetDataTypeView(FldKey);
            Console.WriteLine(string.Format("*** UpdateDataTypeRow ***"));
            Console.WriteLine(string.Format("Original DataTypeView FldKey: {0}  FldNVarChar: {1}  FldBigInt: {2}", dtv.FldKey, dtv.FldNVarChar, dtv.FldBigInt.ToString()));

            // Change DataTypeView
            dtv.FldBigInt = "1911";
            dtv.FldBit    = "false";
            dtv.FldChar   = "zon";
            //dtv.FldDate
            dtv.FldDateTime = "1/9/2012";
            //dtv.FldDateTime2
            dtv.FldDecimal = "2911.11";
            //dtv.FldFloat
            //dtv.FldImage
            dtv.FldInt         = "3911";
            dtv.FldMoney       = "4911.11";
            dtv.FldNChar       = "zonald";
            dtv.FldNText       = "zonnie";
            dtv.FldNumeric     = "5911.11";
            dtv.FldNVarChar    = "zonaldo";
            dtv.FldNVarCharMax = "zjl";
            //dtv.FldReal
            dtv.FldSmallDateTime = "2/9/2012";
            dtv.FldSmallInt      = "69";
            dtv.FldSmallMoney    = "7911.11";
            dtv.FldText          = "zinaldo";
            //TODO: FldTime should be DateTime not Timespan
            //dtv.FldTime = Convert.ToDateTime("3/1/2012 17:32:19");
            //dtv.FldTimeStamp
            dtv.FldTinyInt = "89";
            //dtv.FldUniqueIdentifier
            //dtv.FldVarBinary
            //dtv.FldVarBinaryMax
            dtv.FldVarChar    = "zeynaldo";
            dtv.FldVarCharMax = "zownaldo";
            //dtv.FldXml

            // Save DataType
            dts.SaveDataType(dtv);

            // Get updated DataTypeView
            dtv = dts.GetDataTypeView(FldKey);

            Console.WriteLine(string.Format("Updated DataTypeView FldKey: {0}  FldNVarChar: {1}  FldBigInt: {2}", dtv.FldKey, dtv.FldNVarChar, dtv.FldBigInt.ToString()));
            Console.WriteLine(Environment.NewLine);
        }
        public JsonObject GetDataTypeListView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix)
        {
            JsonObject retMessage = new JsonObject();

            string htmlText = DataTypeView.GetListAllItemView(pageNo, itemsPerPage, dataIndex, templateSuffix);

            if (string.IsNullOrEmpty(htmlText) == true)
            {
                htmlText = "&nbsp;";
            }
            retMessage.Put("html", htmlText);

            return(retMessage);
        }
Example #11
0
        public Segment AddSegment(Packet currentPacket)
        {
            var segment = new Segment {
                Name        = "",
                Description = "",
                OrderId     = currentPacket.Segments.Count + 1,
                Type        = new DataTypeView {
                    Type = DataType.Byte
                },
                Size = DataTypeView.SizeOfType(DataType.Byte)
            };

            currentPacket.Segments.Add(segment);
            return(segment);
        }
Example #12
0
        private static void AddDataTypeRow()
        {
            DataTypeView dtv = new DataTypeView();

            dtv.FldKey    = 0;
            dtv.FldBigInt = "1111";
            dtv.FldBit    = "true";
            dtv.FldChar   = "ron";
            //dtv.FldDate
            dtv.FldDateTime = "1/1/2012";
            //dtv.FldDateTime2
            dtv.FldDecimal = "2111.11";
            //dtv.FldFloat
            //dtv.FldImage
            dtv.FldInt         = "3111";
            dtv.FldMoney       = "4111.11";
            dtv.FldNChar       = "ronald";
            dtv.FldNText       = "ronnie";
            dtv.FldNumeric     = "5111.11";
            dtv.FldNVarChar    = "ronaldo";
            dtv.FldNVarCharMax = "rjl";
            //dtv.FldReal
            dtv.FldSmallDateTime = "2/1/2012";
            dtv.FldSmallInt      = "6";
            dtv.FldSmallMoney    = "7111.11";
            dtv.FldText          = "rinaldo";
            //TODO: FldTime should be DateTime not Timespan
            //dtv.FldTime = Convert.ToDateTime("3/1/2012 17:32:19");
            //dtv.FldTimeStamp
            dtv.FldTinyInt = "8";
            //dtv.FldUniqueIdentifier
            //dtv.FldVarBinary
            //dtv.FldVarBinaryMax
            dtv.FldVarChar    = "reynaldo";
            dtv.FldVarCharMax = "rownaldo";
            //dtv.FldXml
            newDataTypeFldKey = dts.SaveDataType(dtv);
            Console.WriteLine(string.Format("*** AddDataTypeRow ***"));
            Console.WriteLine(string.Format("New FldKey: {0}", newDataTypeFldKey.ToString()));
            Console.WriteLine(Environment.NewLine);
        }
Example #13
0
        private void CbDataTypeOnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (CurrentSegment == null)
            {
                return;
            }
            if (CbDataType.SelectedIndex == -1)
            {
                return;
            }
            CurrentSegment.Type = (DataTypeView)CbDataType.SelectedItem;
            var fixedSize = DataTypeView.SizeOfType(CurrentSegment.Type.Type);

            if (fixedSize > 0)
            {
                CurrentSegment.Size      = fixedSize;
                TxtSegmentSize.Text      = CurrentSegment.Size.ToString(CultureInfo.InvariantCulture);
                TxtSegmentSize.IsEnabled = false;
            }
            else
            {
                TxtSegmentSize.IsEnabled = true;
            }
        }