//向显示表中插入一条烟 private void InsertOnePackageDetail(PickPackageDetail _packagedetail) { DataRow tempp = packageShowTable.NewRow(); tempp["productName"] = _packagedetail.Product.ProductName; tempp["productID"] = _packagedetail.ProductID; tempp["quantity"] = _packagedetail.Quantity; tempp["readed"] = "0"; this.PerformSafely(() => packageShowTable.Rows.Add(tempp)); //packageShowTable.Rows.Add(tempp); }
public async Task <int> InsertPickPackageDetail(PickPackageDetail _temp) { try { dataBase.PackageDetails.Add(new PickPackageDetail { PickPackageID = _temp.PickPackageID, PickPackageDetailID = _temp.PickPackageDetailID, Quantity = _temp.Quantity, Readed = _temp.Readed, ProductID = _temp.ProductID }); Console.WriteLine("ok"); return(await dataBase.SaveChangesAsync()); } catch (Exception ex) { Console.WriteLine(ex.Message); return(0); } }
//插入一条数据到packageDetail表中,并且显示 private void ShowPackageDetailTable(PickPackageDetail _temp) { var row = packageDetailsShowTable.NewRow(); row["商品名称"] = localDatabase.dataBase.Database.SqlQuery <string>("select [ProductName] from [Product] where [ProductID]=" + _temp.ProductID).FirstOrDefault(); row["商品ID"] = _temp.ProductID; row["数量"] = _temp.Quantity; row["已读数量"] = _temp.Readed; if (_temp.Result == (int)ReadResult.OK) { row["结果信息"] = "正常"; } else if (_temp.Result == 0) { row["结果信息"] = "还未读取"; } else { row["结果信息"] = "异常"; } this.PerformSafely(() => packageDetailsShowTable.Rows.Add(row)); }
//分析一个包中条烟数量情况 private void ResultAnalysis(int _result, int _abnormalCount, int _allCount, PickPackageDetail _pd) { var pdresult = orderHandle.localDatabase.dataBase.PackageDetails.FirstOrDefault(c => c.PickPackageDetailID == _pd.PickPackageDetailID); var _ps = orderHandle.localDatabase.dataBase.Packages.FirstOrDefault(c => c.PickPackageID == _pd.PickPackageID); PickException exception = null; string message = ""; if (_result == 0) { pdresult.Details = "正常"; pdresult.Readed = _pd.Readed; pdresult.Result = (int)ReadResult.OK; } else if (_result > 0) { message = "缺少 " + _pd.Product.ProductName.Trim() + " , " + _pd.ProductID.Trim() + "," + _result.ToString() + "条"; pdresult.Details = "缺少 " + _result.ToString() + "条"; pdresult.Readed = _pd.Readed; pdresult.Result = (int)ReadResult.LESS; exception = new PickException(); exception.CustomerID = _ps.CustomerID; exception.CustomerName = _ps.CustomerName; exception.Detail = "少烟"; exception.PackID = _ps.PackID; exception.PickDate = _ps.PickDate; exception.ProductName = _pd.Product.ProductName; exception.LineID = _ps.LineID; exception.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); } else { message = ("多 " + _pd.Product.ProductName.Trim() + " , " + _pd.ProductID.Trim() + "," + (-_result).ToString() + "条"); pdresult.Details = "多 " + (-_result).ToString() + "条"; pdresult.Readed = _pd.Readed; pdresult.Result = (int)ReadResult.MORE; exception = new PickException(); exception.CustomerID = _ps.CustomerID; exception.CustomerName = _ps.CustomerName; exception.Detail = "多烟"; exception.PackID = _ps.PackID; exception.PickDate = _ps.PickDate; exception.ProductName = _pd.Product.ProductName; exception.LineID = _ps.LineID; exception.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); } try { orderHandle.localDatabase.dataBase.Entry(pdresult).State = System.Data.Entity.EntityState.Modified; if (exception != null) { orderHandle.localDatabase.dataBase.PickExceptions.Add(exception); } orderHandle.localDatabase.dataBase.SaveChanges(); } catch (Exception ex) { Debug.WriteLine(ex.InnerException.Message); } this.PerformSafely(() => { listBoxMessageShow.Items.Add(new CCWin.SkinControl.SkinListBoxItem { Text = message }); }); }