📄 typtest.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
[Serializable]
[SqlUserDefinedType(Format.Native)]
public struct typPoint : INullable
{
private bool m_Null;
private double m_x;
private double m_y;
public override string ToString()
{
if (this.IsNull)
return "NULL";
else
return this.m_x + ":" + this.m_y;
}
public bool IsNull
{
get
{
return m_Null;
}
}
public static typPoint Null
{
get
{
typPoint pt = new typPoint();
pt.m_Null = true;
return pt;
}
}
public static typPoint Parse(SqlString s)
{
if (s.IsNull)
return Null;
else
{
//Parse input string here to separate out points
typPoint pt = new typPoint();
char[] parms = new char[1];
parms[0] = ':';
string str = (string)s;
string[] xy = str.Split(parms);
pt.X = double.Parse(xy[0]);
pt.Y = double.Parse(xy[1]);
return pt;
}
}
public static double Sum(typPoint p )
{
return p.X + p.Y;
}
public double X
{
get { return m_x; }
set { m_x = value; }
}
public double Y
{
get { return m_y; }
set { m_y = value; }
}
}
[Serializable]
[SqlUserDefinedType(Format.Native)]
public struct typBakersDozen : INullable
{
private bool m_Null;
private double m_RealQty;
public override string ToString()
{
return (m_RealQty + (long)m_RealQty / 12).ToString();
}
public bool IsNull
{
get
{
return m_Null;
}
}
public static typBakersDozen Null
{
get
{
typBakersDozen h = new typBakersDozen();
h.m_Null = true;
return h;
}
}
public static typBakersDozen Parse(SqlString s)
{
if (s.IsNull)
return Null;
else
{
typBakersDozen u = new typBakersDozen();
u.RealQty = double.Parse((string)s);
return u;
}
}
public static typBakersDozen ParseDouble(SqlDouble d)
{
if (d.IsNull)
return Null;
else
{
typBakersDozen u = new typBakersDozen();
u.RealQty = (double)d;
return u;
}
}
public double RealQty
{
get { return m_RealQty; }
set { m_RealQty = value; }
}
public double AdjustedQty
{
get
{
return (m_RealQty + (long)m_RealQty / 12);
}
set
{
if (value % 12 == 0)
m_RealQty = value;
else
m_RealQty = value - (long)value / 13;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -