Exemplo n.º 1
0
 public void FromCustomObject(SqlConnection con, IntPtr pUdt)
 {
     if (ID != null)
     {
         SqlUdt.SetValue(con, pUdt, "ID", ID.ToSqlValue());
     }
     if (CheckNo != null)
     {
         SqlUdt.SetValue(con, pUdt, "CheckNo", CheckNo.ToSqlValue());
     }
     if (CheckType != null)
     {
         SqlUdt.SetValue(con, pUdt, "CheckType", CheckType.ToSqlValue());
     }
     if (DutyUser != null)
     {
         SqlUdt.SetValue(con, pUdt, "DutyUser", DutyUser.ToSqlValue());
     }
     if (CheckDesc != null)
     {
         SqlUdt.SetValue(con, pUdt, "CheckDesc", CheckDesc.ToSqlValue());
     }
     if (CheckStatus != null)
     {
         SqlUdt.SetValue(con, pUdt, "CheckStatus", CheckStatus.ToSqlValue());
     }
     if (BeginTime != null)
     {
         SqlUdt.SetValue(con, pUdt, "BeginTime", BeginTime.ToSqlValue());
     }
     if (DoneTime != null)
     {
         SqlUdt.SetValue(con, pUdt, "DoneTime", DoneTime.ToSqlValue());
     }
     if (Remarks != null)
     {
         SqlUdt.SetValue(con, pUdt, "Remarks", Remarks.ToSqlValue());
     }
     if (IsDel != null)
     {
         SqlUdt.SetValue(con, pUdt, "IsDel", IsDel.ToSqlValue());
     }
     if (Creater != null)
     {
         SqlUdt.SetValue(con, pUdt, "Creater", Creater.ToSqlValue());
     }
     if (CreateTime != null)
     {
         SqlUdt.SetValue(con, pUdt, "CreateTime", CreateTime.ToSqlValue());
     }
     if (Modifyer != null)
     {
         SqlUdt.SetValue(con, pUdt, "Modifyer", Modifyer.ToSqlValue());
     }
     if (ModifyTime != null)
     {
         SqlUdt.SetValue(con, pUdt, "ModifyTime", ModifyTime.ToSqlValue());
     }
 }
Exemplo n.º 2
0
 public void ToCustomObject(SqlConnection con, IntPtr pUdt)
 {
     ID          = SqlUdt.GetValue(con, pUdt, "ID").ToInt32();
     CheckNo     = SqlUdt.GetValue(con, pUdt, "CheckNo").ToDBString();
     CheckType   = SqlUdt.GetValue(con, pUdt, "CheckType").ToInt32();
     DutyUser    = SqlUdt.GetValue(con, pUdt, "DutyUser").ToDBString();
     CheckDesc   = SqlUdt.GetValue(con, pUdt, "CheckDesc").ToDBString();
     CheckStatus = SqlUdt.GetValue(con, pUdt, "CheckStatus").ToInt32();
     BeginTime   = SqlUdt.GetValue(con, pUdt, "BeginTime").ToDateTimeNull();
     DoneTime    = SqlUdt.GetValue(con, pUdt, "DoneTime").ToDateTimeNull();
     Remarks     = SqlUdt.GetValue(con, pUdt, "Remarks").ToDBString();
     IsDel       = SqlUdt.GetValue(con, pUdt, "ISDEL").ToInt32();
     Creater     = SqlUdt.GetValue(con, pUdt, "CREATER").ToDBString();
     CreateTime  = SqlUdt.GetValue(con, pUdt, "CREATETIME").ToDateTime();
     Modifyer    = SqlUdt.GetValue(con, pUdt, "MODIFYER").ToDBString();
     ModifyTime  = SqlUdt.GetValue(con, pUdt, "MODIFYTIME").ToDateTimeNull();
 }
Exemplo n.º 3
0
 public void ToCustomObject(SqlConnection con, IntPtr pUdt)
 {
     ID            = SqlUdt.GetValue(con, pUdt, "ID").ToInt32();
     CheckID       = SqlUdt.GetValue(con, pUdt, "CheckID").ToInt32();
     WarehouseNo   = SqlUdt.GetValue(con, pUdt, "WarehouseNo").ToDBString();
     HouseNo       = SqlUdt.GetValue(con, pUdt, "HouseNo").ToDBString();
     AreaNo        = SqlUdt.GetValue(con, pUdt, "AreaNo").ToDBString();
     MaterialNo    = SqlUdt.GetValue(con, pUdt, "MaterialNo").ToDBString();
     MaterialDesc  = SqlUdt.GetValue(con, pUdt, "MaterialDesc").ToDBString();
     AccountQty    = SqlUdt.GetValue(con, pUdt, "AccountQty").ToDecimal();
     ScanQty       = SqlUdt.GetValue(con, pUdt, "ScanQty").ToDecimal();
     Status        = SqlUdt.GetValue(con, pUdt, "Status").ToInt32();
     StockTime     = SqlUdt.GetValue(con, pUdt, "StockTime").ToDateTimeNull();
     Operator      = SqlUdt.GetValue(con, pUdt, "Operator").ToDBString();
     OperationTime = SqlUdt.GetValue(con, pUdt, "OperationTime").ToDateTimeNull();
     ProfitLoss    = SqlUdt.GetValue(con, pUdt, "ProfitLoss").ToInt32();
     DifferenceQty = SqlUdt.GetValue(con, pUdt, "DifferenceQty").ToDecimal();
     IsDel         = SqlUdt.GetValue(con, pUdt, "ISDEL").ToInt32();
     Creater       = SqlUdt.GetValue(con, pUdt, "CREATER").ToDBString();
     CreateTime    = SqlUdt.GetValue(con, pUdt, "CREATETIME").ToDateTime();
     Modifyer      = SqlUdt.GetValue(con, pUdt, "MODIFYER").ToDBString();
     ModifyTime    = SqlUdt.GetValue(con, pUdt, "MODIFYTIME").ToDateTimeNull();
 }
Exemplo n.º 4
0
 public void FromCustomObject(SqlConnection con, IntPtr pUdt)
 {
     SqlUdt.SetValue(con, pUdt, "ID", ID.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "CheckID", CheckID.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "WarehouseNo", WarehouseNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "HouseNo", HouseNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "AreaNo", AreaNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "MaterialNo", MaterialNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "MaterialDesc", MaterialDesc.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "AccountQty", AccountQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ScanQty", ScanQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Status", Status.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "StockTime", StockTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Operator", Operator.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "OperationTime", OperationTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ProfitLoss", ProfitLoss.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "DifferenceQty", DifferenceQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "IsDel", IsDel.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Creater", Creater.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "CreateTime", CreateTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Modifyer", Modifyer.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ModifyTime", ModifyTime.ToSqlValue());
 }
Exemplo n.º 5
0
        public void LoadFromString(
      String              AString,
      Char                ASeparator,
      TLoadValueCondition ALoadValueCondition = TLoadValueCondition.lvcAlways,
      Char                AParamPrefix        = '\0',
      TParams             AParams             = null
    )
        {
            if (String.IsNullOrEmpty(AString)) return;
              //TLoadValueCondition LLoadValueCondition = Pub.LoadValueConditionParser(ALoadValueCondition);

              Pub.NamedItemsParser Parser =
            new Pub.NamedItemsParser
            (
              AString,
              new Char[] { ASeparator, '\r', '\n' },
              true
             );

              while (Parser.MoveNext())
              {
            try
            {
              String LName  = Parser.Current.Name.Trim();
              String SValue = Parser.Current.Value;
              if(Parser.Current.Quote == '\0')
            SValue = SValue.Trim();

              Object LValue;
              if
              (
            AParamPrefix != '\0'
                && Parser.Current.Quote == '\0'
                //&& String.IsNullOrEmpty(Parser.Current.CastAs)
                && !String.IsNullOrEmpty(SValue)
                && SValue[0] == AParamPrefix
              )
              {
            if (AParams != null && AParams.FData.TryGetValue(SValue.Substring(1), out LValue))
            {
              if (ALoadValueCondition != TLoadValueCondition.lvcIfNotPresent || !FData.ContainsKey(LName))
                AddParam(LName, LValue);
            }
            else if (ALoadValueCondition == TLoadValueCondition.lvcAlways)
              AddParam(LName, DBNull.Value);
              }
              else if (ALoadValueCondition != TLoadValueCondition.lvcIfNotPresent || !FData.ContainsKey(LName))
              {
            // Парсим значение
            SqlDbType LSqlDbType = Sql.TypeFromString(Parser.Current.CastAs);

            if (LSqlDbType == SqlDbType.Udt)
              LValue = new SqlUdt(Parser.Current.CastAs, SValue);
            else
              LValue = Sql.ValueFromString(SValue, LSqlDbType, Sql.ValueDbStyle.SQL);
            AddParam(LName, LValue);
              }

            }
            catch (Exception E)
            {
              throw new Exception(String.Format("Неверно задано значение TParams '{0}': {1}", AString, E.Message));
            }
              }
        }
Exemplo n.º 6
0
        private Boolean ReadValues(System.IO.BinaryReader r)
        {
            Int32 count;
              if(r.BaseStream.Length == 0) return false;
              count = Sql.Read7BitEncodedInt(r);

              if (count == 0) return true;

              for (Int32 i = 0; i < count; i++)
              {
            String    name  = r.ReadString();
            SqlDbType LType = (SqlDbType)r.ReadUInt16();
            Object    value = null;
            Int32 len;
            //Int32 lcid;
            //SqlCompareOptions co;

            switch (LType)
            {
              case SqlDbType.Bit      : value = new SqlBoolean(r.ReadBoolean()); break;
              case SqlDbType.TinyInt  : value = new SqlByte(r.ReadByte()); break;
              case SqlDbType.SmallInt : value = new SqlInt16((Int16)r.ReadInt16()); break;
              case SqlDbType.Int      : value = new SqlInt32((Int32)r.ReadInt32()); break;
              case SqlDbType.BigInt   : value = new SqlInt64(r.ReadInt64()); break;

              case SqlDbType.Binary   :
              case SqlDbType.VarBinary: len = r.ReadUInt16(); value = new SqlBytes(r.ReadBytes(len)); break;

              case SqlDbType.Char     :
              case SqlDbType.VarChar  : //value = new Sql.SqlAnsiString(r); break;
              case SqlDbType.NChar:
              case SqlDbType.NVarChar:
            //co = (SqlCompareOptions)r.ReadUInt16();
            //lcid = r.ReadInt32();
            //value = new SqlString(r.ReadString(), lcid, co);
            value = new SqlString(r.ReadString());
            break;

              case SqlDbType.DateTime     : value = new SqlDateTime(DateTime.FromBinary(r.ReadInt64())); break;
              case SqlDbType.SmallDateTime:
              case SqlDbType.Date         :
              case SqlDbType.DateTime2    : value = DateTime.FromBinary(r.ReadInt64()); break;
              case SqlDbType.Time         : value = TimeSpan.FromTicks(r.ReadInt64()); break;
              case SqlDbType.DateTimeOffset:
            DateTime LDateTime = DateTime.FromBinary(r.ReadInt64());
            value = new DateTimeOffset(LDateTime, TimeSpan.FromTicks(r.ReadInt64()));
            break;

              case SqlDbType.Decimal: value = new SqlDecimal(r.ReadDecimal()); break;
              case SqlDbType.Float  : value = new SqlDouble(r.ReadDouble()); break;
              // Not support SqlDbType.Image
              case SqlDbType.Money  : value = new SqlMoney(r.ReadDecimal()); break;
              case SqlDbType.Real   : value = new SqlSingle(r.ReadDouble()); break;
              case SqlDbType.SmallMoney: value = new SqlMoney(r.ReadDecimal()); break;
              // Not support SqlDbType.Structured
              // Not support SqlDbType.Text
              // Not support SqlDbType.Timestamp
              case SqlDbType.UniqueIdentifier: value = new SqlGuid(r.ReadString()); break;
              // Not support SqlDbType.Variant
              case SqlDbType.Xml:
            XmlReader rXml = XmlReader.Create(new System.IO.StringReader(r.ReadString()));
            value = new SqlXml(rXml);
            break;

              case SqlDbType.Udt:
            // TODO: Пока поддержа только TParams
            //String LTypeName = r.ReadString();
            //value = CreateUdtObject(LTypeName);
            //if (value is IBinarySerialize)
            //  (value as IBinarySerialize).Read(r);
            //else
            //  throw new Exception(String.Format("Невозможно прочитать данные типа UDT '{0}' - не поддерживается IBinarySerialize", LTypeName));
            value = new SqlUdt(r);
            break;

              default:
            throw new Exception(String.Format("Невозможно прочитать данные, тип '{0}' не поддерживается текущей версией {1}", LType.ToString(), this.GetType().Name));
              // Not support SqlDbType.NText
            }
            if (value != null) FData.Add(name, value);
              }

              return true;
        }