我有以下问题
public const string UpdateSample =
@"UPDATE subReceivingQC
SET Clerk=@Clerk, Comments=@Comments, CommentsProd=@CommentsProd, MassOff=@MassOff,
PalletID=@PalletID, QCDate=@QCDate, QtyInspected=@QtyInspected, StatusClerk=@StatusClerk,
StatusSupervisor=@StatusSupervisor, Supervisor=@Supervisor, PackOut=@PackOut
WHERE GRV=@GRV AND PalletSeq=@PalletSeq AND SampleNo=@SampleNo";
// Update sample
query = DatabaseConstants.UpdateSample;
args = new DynamicParameters();
args.Add("@Clerk", sample.Clerk, DbType.String);
args.Add("@Comments", sample.Comments, DbType.String);
args.Add("@CommentsProd", sample.CommentsProd, DbType.String);
args.Add("@MassOff", sample.MassOff, DbType.String);
args.Add("@PackOut", sample.PackOut, DbType.String);
args.Add("@PalletID", sample.PalletID, DbType.String);
args.Add("@QCDate", sample.QCDate, DbType.Date);
args.Add("@QtyInspected ", sample.QtyInspected, DbType.Decimal);
args.Add("@StatusClerk", sample.StatusClerk, DbType.String);
args.Add("@StatusSupervisor", sample.StatusSupervisor, DbType.String);
args.Add("@Supervisor", sample.Supervisor, DbType.String);
args.Add("@GRV", sample.GRV, DbType.Int64);
args.Add("@PalletSeq", sample.PalletSeq, DbType.Int16);
args.Add("@SampleNo", sample.SampleNo, DbType.Int16);
using (var db = new OleDbConnection(connectionString))
{
output += db.Execute(query, args);
}
现在
MassOff
和
PackOut
都是那种类型的
,其中访问数据类型如下:
奇怪的是,代码对属性非常有效
马索夫
,但在为
帕科特
我明白了
条件表达式中的数据类型无效
DbType.Decimal
DbType.Double
但没什么区别。
帕科特
价值观。
例如,当我尝试传入这些值时:
马索夫
: 9.5
帕科特
它对你有用
但不是
帕科特
示例类
public class Sample :
QCObject, IGriddable
{
private string imagesPath = ConfigurationManager.AppSettings["ImagesPath"];
private string[] columnHeaders;
public string[] ColumnHeaders {
get
{
if(columnHeaders.IsNullOrEmpty())
{
return new string[] { "SampleNo", "Date", /*"QCDate",*/ "StatusClerk", "StatusSupervisor" };
}
else
{
return columnHeaders;
}
}
set { columnHeaders = value; } }
private string rowLinkPrefix;
public string RowLinkPrefix {
get
{
if(string.IsNullOrWhiteSpace(rowLinkPrefix))
{
return $"/receiving/{GRV}/{Pallet.PalletSeq}/";
}
else
{
return rowLinkPrefix;
}
}
set { rowLinkPrefix = value; } }
public bool Selectable { get; } = true;
public Pallet Pallet { get; set; }
// Should be 100 - (massoff/qtinspected) but building this manually
// at the moment due to lack of data integrity
[DisplayName("Pack Out")]
public double PackOut { get; set; }
[DisplayName("Pack Out Percentage")]
public double PackoutPerc { get; set; }
[DisplayName("Percentage")]
public double Perc { get; set; }
[DisplayName("Mass Off")]
public double MassOff { get; set; }
[DisplayName("Production Comments")]
public string CommentsProd { get; set; }
[DisplayName("Technical Comments")]
public string Comments { get; set; }
[DisplayName("Quantity Inspected")]
public double QtyInspected { get; set; }
[DisplayName("Sample Number")]
public int SampleNo { get; set; }
[DisplayName("Status Clerk")]
public string StatusClerk { get; set; }
[DisplayName("Status Supervisor")]
public string StatusSupervisor { get; set; }
[DisplayName("Product Spec")]
public string ProductSpec { get; set; }
[DisplayName("PO Container")]
public string POContainer { get; set; }
public string Supervisor { get; set; }
public string Clerk { get; set; }
// For required db params
public string GRV { get; set; }
public string PalletID { get; set; }
[DisplayName("Pallet")]
public string PalletSeq { get; set; }
[DisplayName("Date")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime QCDate { get; set; }
public string Date { get { return QCDate.ToString("dd/MM/yyyy"); } } // My generic WebGrid solution does not alllow me to change thed ate formats, so use this instead
// Each defect status needs to be saved as a (DB)subQCItems item
public List<QCItem> Defects { get; set; } = new List<QCItem>();
public IEnumerable<string> Users { get; set; } = new List<string>();
public Sample()
{
var access = new Access();
Users = access.GetUsers();
}
public IEnumerable<string> Images
{
get
{
string physicalDir;
var dir = Path.Combine(imagesPath, $@"{Pallet.Grv.GRVNo}\{Pallet.PalletSeq}\{SampleNo}\");
physicalDir = dir;
if (Path.IsPathRooted(dir))
{
physicalDir = dir;
}
else
{
physicalDir = HttpContext.Current.Server.MapPath(dir);
}
if (!Directory.Exists(physicalDir))
Directory.CreateDirectory(physicalDir);
foreach (var filePath in Directory.GetFiles(physicalDir).Where(f => f != null))
{
yield return Path.Combine(dir, Path.GetFileName(filePath));
}
}
}
public void SaveImages(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files.Where(f => f != null))
{
var dir = $@"{imagesPath}/{Pallet.Grv.GRVNo}/{Pallet.PalletSeq}/{SampleNo}";
var physicalDir = HttpContext.Current.Server.MapPath(dir);
var imageDirInfo = Directory.CreateDirectory(physicalDir);
var counter = imageDirInfo.EnumerateFiles().Count() + 1;
var path = Path.Combine($@"{physicalDir}", $"{counter}{Path.GetExtension(file.FileName)}");
file.SaveAs(path);
counter++;
}
}
}