public int Count() { using (var db = new SortingDbContext()) { return(db.WaveApi.Count()); } }
/// <summary> /// 持久化数据到数据库 /// </summary> public void SaveAync() { using (var db = new SortingDbContext()) { var slave = db.SlaveInfo.Include("LatticeInfo").Include("LatticeInfo.Product").FirstOrDefault(o => o.Id == SlaveInfo.Id); if (slave == null) { return; } slave.IsCompleteHand = SlaveInfo.IsCompleteHand; SlaveInfo.LatticeInfo.ForEach(o => { var lattice = slave.LatticeInfo.First(b => b.LatticeNo == o.LatticeNo); lattice.OrderNo = o.OrderNo; lattice.Status = o.Status; lattice.IsPrint = o.IsPrint; o.Product.ForEach(p => { var product = lattice.Product.FirstOrDefault(i => i.BarCode == p.BarCode); if (product == null) { lattice.Product.Add(p); } else { product.PutNum = p.PutNum; product.Status = p.Status; } }); }); db.SlaveInfo.AddOrUpdate(slave); db.SaveChangesAsync(); } }
public SlaveInfo WaveApiTransformSlaveInfo(WaveApi wave) { using (var db = new SortingDbContext()) { var latticeInfoList = new List <LatticeInfo>(); Enumerable.Range(1, 50).ToList().ForEach(o => latticeInfoList.Add( new LatticeInfo { LatticeNo = o.ToString(), Status = LatticeStatus.None, Product = new List <Product>() } )); //1.更新WaveApi为已作业 wave.Status = WaveStatus.Work; db.WaveApi.AddOrUpdate(wave); //2.载入到SlaveInfo var slaveInfo = db.SlaveInfo.Add(new SlaveInfo() { WaveNo = wave.WaveNo, IsCompleteHand = false, NeedWaitPutByApi = wave.OrderApi.Where(o => o.Status == OrderStatus.Normal).Sum(o => o.ProductApi.Sum(p => p.Num)), LatticeInfo = latticeInfoList }); bool isSuccess = db.SaveChanges() > 0; return(isSuccess ? slaveInfo : null); } }
public SortOrder[] GetSortOrder(string beginDate, string endDate, string sortOrders) { string sql = @" SELECT [ORDER_ID] AS OrderID ,[ORG_CODE] AS CompanyCode ,[SALE_REG_CODE] AS SaleRegionCode ,[ORDER_DATE] AS OrderDate ,[ORDER_TYPE] AS OrderType ,[CUST_CODE] AS CustomerCode ,[CUST_NAME] AS CustomerName ,[QUANTITY_SUM] AS QuantitySum ,[AMOUNT_SUM] AS AmountSum ,[DETAIL_NUM] AS DetailNum ,[DELIVER_ORDER] AS DeliverOrder ,getdate() AS DeliverDate ,'' AS Description ,[ISACTIVE] AS IsActive ,[UPDATE_DATE] AS UpdateTime ,[DELIVER_LINE_CODE] AS DeliverLineCode FROM [V_WMS_SORT_ORDER]"; sql = sql + " WHERE ORDER_DATE>='" + beginDate + "' AND ORDER_DATE<='" + endDate + "'"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <SortOrder>(sql).ToArray()); } }
public Domain.Models.UserInfo GetLastUserInfo() { using (var db = new SortingDbContext()) { return(db.UserInfo.OrderByDescending(o => o.LastLoginTime).FirstOrDefault()); } }
public DeliverLine[] GetDeliverLine(string deloverLines) { string sql = @"SELECT [DELIVER_LINE_CODE] AS DeliverLineCode ,[LINE_TYPE] AS CustomCode ,[DELIVER_LINE_NAME] AS DeliverLineName ,[DIST_STA_CODE] AS DistCode ,[DELIVER_LINE_ORDER] AS DeliverOrder ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DELIVER_LINE]"; sql = sql + " WHERE DELIVER_LINE_CODE NOT IN('" + deloverLines + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <DeliverLine>(@" SELECT [DELIVER_LINE_CODE] AS DeliverLineCode ,[LINE_TYPE] AS CustomCode ,[DELIVER_LINE_NAME] AS DeliverLineName ,[DIST_STA_CODE] AS DistCode ,[DELIVER_LINE_ORDER] AS DeliverOrder ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DELIVER_LINE]").ToArray()); } }
/// <summary> /// 获取批次 /// </summary> /// <param name="condition"></param> /// <returns></returns> public SlaveInfo GetSlaveInfo(Func <SlaveInfo, bool> condition) { using (var db = new SortingDbContext()) { return(db.SlaveInfo.Include("LatticeInfo").Include("LatticeInfo.Product").FirstOrDefault(condition)); } }
public void UpdateRemeberUserName(Domain.Models.UserInfo userInfo, string email) { using (var db = new SortingDbContext()) { var user = db.UserInfo.FirstOrDefault(o => o.UserId == userInfo.UserId); if (user == null) { db.UserInfo.Add(new Domain.Models.UserInfo { IsRemeberUserName = true, LastLoginTime = DateTime.Now, Pcid = userInfo.Pcid, PcName = userInfo.PcName, UserId = userInfo.UserId, UserName = userInfo.UserName, Email = email }); db.SaveChangesAsync(); } else { user.LastLoginTime = DateTime.Now; user.IsRemeberUserName = true; db.UserInfo.AddOrUpdate(user); db.SaveChanges(); } } }
public UnitList[] GetUnitList(string unitLists) { string sql = @"SELECT [BRAND_ULIST_CODE] AS UnitListCode ,[N_BRAND_ULIST_CODE] AS UniformCode ,[BRAND_ULIST_NAME] AS UnitListName ,[BRAND_UNIT_CODE_01] AS UnitCode01 ,[BRAND_UNIT_NAME_01] AS UnitName01 ,[QTY_01] AS Quantity01 ,[BRAND_UNIT_CODE_02] AS UnitCode02 ,[BRAND_UNIT_NAME_02] AS UnitName02 ,[QTY_02] AS Quantity02 ,[BRAND_UNIT_CODE_03] AS UnitCode03 ,[BRAND_UNIT_NAME_03] AS UnitName03 ,[QTY_03] AS Quantity03 ,[BRAND_UNIT_CODE_04] AS UnitCode04 ,[BRAND_UNIT_NAME_04] AS UnitName04 ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_BRAND_ULIST]"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <UnitList>(sql).ToArray()); } }
public SortOrder[] GetSortOrder(string beginDate, string endDate, string sortOrders) { string sql = @" SELECT [ORDER_ID] AS OrderID ,[ORG_CODE] AS CompanyCode ,[SALE_REG_CODE] AS SaleRegionCode ,[ORDER_DATE] AS OrderDate ,[ORDER_TYPE] AS OrderType ,[CUST_CODE] AS CustomerCode ,[CUST_NAME] AS CustomerName ,[QUANTITY_SUM] AS QuantitySum ,[AMOUNT_SUM] AS AmountSum ,[DETAIL_NUM] AS DetailNum ,[DELIVER_ORDER] AS DeliverOrder ,getdate() AS DeliverDate ,'' AS Description ,[ISACTIVE] AS IsActive ,[UPDATE_DATE] AS UpdateTime ,[DELIVER_LINE_CODE] AS DeliverLineCode FROM [V_WMS_SORT_ORDER]"; sql = sql + " WHERE ORDER_DATE>='" + beginDate + "' AND ORDER_DATE<='" + endDate + "'"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<SortOrder>(sql).ToArray(); } }
public DeliverLine[] GetDeliverLine(string deloverLines) { string sql = @"SELECT [DELIVER_LINE_CODE] AS DeliverLineCode ,[LINE_TYPE] AS CustomCode ,[DELIVER_LINE_NAME] AS DeliverLineName ,[DIST_STA_CODE] AS DistCode ,[DELIVER_LINE_ORDER] AS DeliverOrder ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DELIVER_LINE]"; sql = sql + " WHERE DELIVER_LINE_CODE NOT IN('" + deloverLines + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<DeliverLine>(@" SELECT [DELIVER_LINE_CODE] AS DeliverLineCode ,[LINE_TYPE] AS CustomCode ,[DELIVER_LINE_NAME] AS DeliverLineName ,[DIST_STA_CODE] AS DistCode ,[DELIVER_LINE_ORDER] AS DeliverOrder ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DELIVER_LINE]").ToArray(); } }
public SysConfig Get() { using (var db = new SortingDbContext()) { return(db.SysConfig.FirstOrDefault()); } }
public bool Save(SysConfig entity) { using (var db = new SortingDbContext()) { db.SysConfig.AddOrUpdate(entity); return(db.SaveChanges() > 0); } }
public bool AddOrUpdate(WaveApi waveList) { using (var db = new SortingDbContext()) { db.WaveApi.AddOrUpdate(waveList); return(db.SaveChanges() > 0); } }
private void button1_Click(object sender, EventArgs e) { using (var db = new SortingDbContext()) { db.WaveApi.RemoveRange(db.WaveApi); db.SaveChanges(); } }
public void Delete(Domain.Models.UserInfo curUser) { using (var db = new SortingDbContext()) { var user = db.UserInfo.FirstOrDefault(o => o.UserId == curUser.UserId); db.UserInfo.Remove(user); db.SaveChanges(); } }
/// <summary> /// 获取OrderApi /// </summary> /// <param name="waveNo"></param> /// <param name="productCode"></param> /// <returns></returns> public List <OrderApi> GetOrderApiList(string waveNo, string barCode) { using (var db = new SortingDbContext()) { var result = from wave in db.WaveApi from order in wave.OrderApi from product in order.ProductApi where wave.WaveNo == waveNo && product.BarCode == barCode && order.Status == OrderStatus.Normal select order; return(result.Include("ProductApi").ToList()); } }
/// <summary> /// 清楚历史旧数据 /// </summary> /// <param name="PreDay"></param> public void ClearDataAsync(int PreDay = 7) { using (var db = new SortingDbContext()) { var date = DateTime.Now.AddDays(-PreDay); var waveList = db.WaveApi.Include("OrderApi").Include("OrderApi.ProductApi").Where(o => o.LastTime <= date); var slave = db.SlaveInfo.Join(waveList, s => s.WaveNo, w => w.WaveNo, (s, w) => s).Include("LatticeInfo").Include("LatticeInfo.Product"); db.WaveApi.RemoveRange(waveList); db.SlaveInfo.RemoveRange(slave); db.SaveChangesAsync(); } }
public Unit[] GetUnit(string units) { string sql = @" SELECT [BRAND_UNIT_CODE]+[COUNT] AS UnitCode ,[BRAND_UNIT_NAME] AS UnitName ,[COUNT] AS COUNT FROM [V_WMS_SORT_ORDER_DETAIL] GROUP BY [BRAND_UNIT_CODE]+[COUNT],[BRAND_UNIT_NAME],[COUNT]"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <Unit>(sql).ToArray()); } }
public Unit[] GetUnit(string units) { string sql = @" SELECT [BRAND_UNIT_CODE]+[COUNT] AS UnitCode ,[BRAND_UNIT_NAME] AS UnitName ,[COUNT] AS COUNT FROM [V_WMS_SORT_ORDER_DETAIL] GROUP BY [BRAND_UNIT_CODE]+[COUNT],[BRAND_UNIT_NAME],[COUNT]"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<Unit>(sql).ToArray(); } }
public SortingDetail(SlaveInfoService slaveInfoService) : this() { this.slaveInfoService = slaveInfoService; var waveNo = slaveInfoService?.SlaveInfo?.WaveNo; if (string.IsNullOrWhiteSpace(waveNo)) { return; } using (var db = new SortingDbContext()) { var result1 = from slave in db.SlaveInfo from lattice in slave.LatticeInfo from product in lattice.Product where slave.WaveNo == waveNo select new SortingDetailView { WaveNo = slave.WaveNo, LatticeNo = lattice.LatticeNo, OrderNo = lattice.OrderNo, latticeStatus = lattice.Status, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = product.PutNum, WaitNum = product.WaitNum, ProductStatus = product.Status, IsPrint = lattice.IsPrint }; var result2 = from wave in db.WaveApi from order in wave.OrderApi from product in order.ProductApi where wave.WaveNo == waveNo && order.Status == Domain.Models.OrderStatus.Normal select new SortingDetailView { WaveNo = wave.WaveNo, LatticeNo = "", OrderNo = order.OrderNo, latticeStatus = Domain.Models.LatticeStatus.None, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = 0, WaitNum = product.Num, ProductStatus = Domain.Models.ProductStatus.None, IsPrint = false }; var data = result1.Concat(result2.Where(o => !result1.Select(r => r.OrderNo).Contains(o.OrderNo))).ToList(); dataGridView1.DataSource = data; } }
public List <SortingDetailView> GetSortingDetail() { string waveNo = this.SlaveInfo.WaveNo; using (var db = new SortingDbContext()) { var result1 = from slave in db.SlaveInfo from lattice in slave.LatticeInfo from product in lattice.Product where slave.WaveNo == waveNo select new SortingDetailView { WaveNo = slave.WaveNo, LatticeNo = lattice.LatticeNo, OrderNo = lattice.OrderNo, latticeStatus = lattice.Status, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = product.PutNum, WaitNum = product.WaitNum, ProductStatus = product.Status, IsPrint = lattice.IsPrint, ProductCode = product.ProductCode, PropertyCode = product.PropertyCode }; var result2 = from wave in db.WaveApi from order in wave.OrderApi from product in order.ProductApi where wave.WaveNo == waveNo && order.Status == Domain.Models.OrderStatus.Normal select new SortingDetailView { WaveNo = wave.WaveNo, LatticeNo = "", OrderNo = order.OrderNo, latticeStatus = Domain.Models.LatticeStatus.None, BarCode = product.BarCode, ProductName = product.ProductName, PutNum = 0, WaitNum = product.Num, ProductStatus = Domain.Models.ProductStatus.None, IsPrint = false, ProductCode = product.ProductCode, PropertyCode = product.PropertyCode }; var data = result1.Concat(result2.Where(o => !result1.Select(r => r.OrderNo).Contains(o.OrderNo))).ToList(); return(data); } }
public InBillMaster[] GetInBillMaster(string inBillMasters) { string sql = @"SELECT [ORDER_ID] AS BillNo, [ORDER_DATE] AS BillDate, [BILL_TYPE] AS BillTypeCode, ['1'] AS Status, [''] AS Description , [ISACTIVE] AS IsActive , [UPDATE_DATE] AS UpdateTime FROM [V_WMS_IN_ORDER]"; sql = sql + "WHERE ORDER_ID NOT IN('" + inBillMasters + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<InBillMaster>(sql).ToArray(); } }
public DateTime GetLastTime() { using (var db = new SortingDbContext()) { var waveApi = db.WaveApi.OrderByDescending(o => o.LastTime).FirstOrDefault(); if (waveApi == null) { return(new DateTime(2017, 8, 27)); } else { return(waveApi.LastTime ?? new DateTime(2017, 8, 27)); } } }
public InBillMaster[] GetInBillMaster(string inBillMasters) { string sql = @"SELECT [ORDER_ID] AS BillNo, [ORDER_DATE] AS BillDate, [BILL_TYPE] AS BillTypeCode, ['1'] AS Status, [''] AS Description , [ISACTIVE] AS IsActive , [UPDATE_DATE] AS UpdateTime FROM [V_WMS_IN_ORDER]"; sql = sql + "WHERE ORDER_ID NOT IN('" + inBillMasters + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <InBillMaster>(sql).ToArray()); } }
public Supplier[] GetSupplier(string SupplierCodes) { string sql = @"SELECT [FACTORY_CODE] AS SupplierCode ,[N_FACTORY_CODE] AS UniformCode ,[FACTORY_N] AS CustomCode ,[FACTORY_NAME] AS SupplierName ,[PROVINCE_NAME] AS ProvinceName ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_FACTORY]"; sql = sql + " WHERE FACTORY_CODE NOT IN('" + SupplierCodes + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<Supplier>(sql).ToArray(); } }
public OutBillDetail[] GetOutBillDetail(string outBillMasters) { string sql = @"SELECT [ORDER_ID] AS BillNo ,[BRAND_CODE] AS ProductCode ,[PRICE] AS Price ,[QUANTITY] AS BillQuantity ,[0] AS AllotQuantity ,[0] AS RealQuantity ,[''] AS Description FROM [V_WMS_OUT_ORDER_DETAIL]"; sql = sql + "WHERE ORDER_ID NOT IN('" + outBillMasters + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<OutBillDetail>(sql).ToArray(); } }
public OutBillDetail[] GetOutBillDetail(string outBillMasters) { string sql = @"SELECT [ORDER_ID] AS BillNo ,[BRAND_CODE] AS ProductCode ,[PRICE] AS Price ,[QUANTITY] AS BillQuantity ,[0] AS AllotQuantity ,[0] AS RealQuantity ,[''] AS Description FROM [V_WMS_OUT_ORDER_DETAIL]"; sql = sql + "WHERE ORDER_ID NOT IN('" + outBillMasters + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <OutBillDetail>(sql).ToArray()); } }
public Supplier[] GetSupplier(string SupplierCodes) { string sql = @"SELECT [FACTORY_CODE] AS SupplierCode ,[N_FACTORY_CODE] AS UniformCode ,[FACTORY_N] AS CustomCode ,[FACTORY_NAME] AS SupplierName ,[PROVINCE_NAME] AS ProvinceName ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_FACTORY]"; sql = sql + " WHERE FACTORY_CODE NOT IN('" + SupplierCodes + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <Supplier>(sql).ToArray()); } }
public DeliverDist[] GetDeliverDist(string deloverDists) { string sql = @"SELECT [DIST_STA_CODE] AS DistCode ,[DIST_STA_N] AS CustomCode ,[DIST_STA_NAME] AS DistName ,[DIST_CTR_CODE] AS DistCenterCode ,[ORG_CODE] AS CompanyCode ,[N_ORG_CODE] AS UniformCode ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DIST_STATION]"; sql = sql + " WHERE DIST_STA_CODE NOT IN('" + deloverDists + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<DeliverDist>(sql).ToArray(); } }
public Product[] GetProduct(string productCodes) { string sql = @" SELECT [BRAND_CODE] AS ProductCode ,[BRAND_NAME] AS ProductName ,[N_UNIFY_CODE] AS UniformCode ,[BRAND_N] AS CustomCode ,[SHORT_CODE] AS ShortCode ,[''] AS UnitListCode ,[UNIT_CODE] AS UnitCode ,[''] AS SupplierCode ,[''] AS BrandCode ,[''] AS AbcTypeCode ,[PRICE_LEVEL_CODE] AS ProductTypeCode ,[''] AS PackTypeCode ,[PRICE_LEVEL_CODE] AS PriceLevelCode ,[''] AS StatisticType ,[BARCODE_PIECE] AS PieceBarcode ,[BARCODE_BAR] AS BarBarcode ,[BARCODE_PACKAGE] AS PackageBarcode ,[''] AS OneProjectBarcode ,[BUY_PRICE] AS BuyPrice ,[TRADE_PRICE] AS TradePrice ,[RETAIL_PRICE] AS RetailPrice ,[COST_PRICE] AS CostPrice ,[IS_FILTERTIP] AS IsFilterTip ,[IS_NEW] AS IsNew ,[IS_FAMOUS] AS IsFamous ,[IS_MAINPRODUCT] AS IsMainProduct ,[IS_MAINPROVINCE] AS IsProvinceMainProduct ,[BELONG_REGION] AS BelongRegion ,[IS_CONFISCATE] AS IsConfiscate ,[IS_ABNORMITY_BRAND] AS IsAbnormity ,[''] AS Description ,[ISACTIVE] AS IsActive ,[UPDATE_DATE] AS UpdateTime FROM [V_WMS_BRAND]"; sql = sql + " WHERE BRAND_CODE NOT IN('" + productCodes + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <Product>(sql).ToArray()); } }
/// <summary> /// 取消波次分拣 /// </summary> /// <param name="slaveInfo">波次信息</param> public bool DeleteSlaveInfo(SlaveInfo slaveInfo = null) { if (slaveInfo == null) { slaveInfo = SlaveInfo; } using (var db = new SortingDbContext()) { db.WaveApi.AddOrUpdate(new WaveApi() { WaveNo = slaveInfo.WaveNo, Status = WaveStatus.Unwork }); var entity = db.SlaveInfo.Include("LatticeInfo").Include("LatticeInfo.Product").FirstOrDefault(o => o.WaveNo == slaveInfo.WaveNo); db.SlaveInfo.Remove(entity); bool isSuccess = db.SaveChanges() > 0; return(isSuccess); } }
public WaveApi Get(string waveNo) { using (var db = new SortingDbContext()) { var wave = db.WaveApi.Include("OrderApi").Include("OrderApi.ProductApi").FirstOrDefault(o => o.WaveNo == waveNo); if (wave == null) { return(null); } if (wave.OrderApi.Exists(o => o.Status == OrderStatus.Normal)) { return(wave); } else { return(null); } } }
public DeliverDist[] GetDeliverDist(string deloverDists) { string sql = @"SELECT [DIST_STA_CODE] AS DistCode ,[DIST_STA_N] AS CustomCode ,[DIST_STA_NAME] AS DistName ,[DIST_CTR_CODE] AS DistCenterCode ,[ORG_CODE] AS CompanyCode ,[N_ORG_CODE] AS UniformCode ,'' AS Description ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_DIST_STATION]"; sql = sql + " WHERE DIST_STA_CODE NOT IN('" + deloverDists + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <DeliverDist>(sql).ToArray()); } }
public Product[] GetProduct(string productCodes) { string sql = @" SELECT [BRAND_CODE] AS ProductCode ,[BRAND_NAME] AS ProductName ,[N_UNIFY_CODE] AS UniformCode ,[BRAND_N] AS CustomCode ,[SHORT_CODE] AS ShortCode ,[''] AS UnitListCode ,[UNIT_CODE] AS UnitCode ,[''] AS SupplierCode ,[''] AS BrandCode ,[''] AS AbcTypeCode ,[PRICE_LEVEL_CODE] AS ProductTypeCode ,[''] AS PackTypeCode ,[PRICE_LEVEL_CODE] AS PriceLevelCode ,[''] AS StatisticType ,[BARCODE_PIECE] AS PieceBarcode ,[BARCODE_BAR] AS BarBarcode ,[BARCODE_PACKAGE] AS PackageBarcode ,[''] AS OneProjectBarcode ,[BUY_PRICE] AS BuyPrice ,[TRADE_PRICE] AS TradePrice ,[RETAIL_PRICE] AS RetailPrice ,[COST_PRICE] AS CostPrice ,[IS_FILTERTIP] AS IsFilterTip ,[IS_NEW] AS IsNew ,[IS_FAMOUS] AS IsFamous ,[IS_MAINPRODUCT] AS IsMainProduct ,[IS_MAINPROVINCE] AS IsProvinceMainProduct ,[BELONG_REGION] AS BelongRegion ,[IS_CONFISCATE] AS IsConfiscate ,[IS_ABNORMITY_BRAND] AS IsAbnormity ,[''] AS Description ,[ISACTIVE] AS IsActive ,[UPDATE_DATE] AS UpdateTime FROM [V_WMS_BRAND]"; sql = sql + " WHERE BRAND_CODE NOT IN('" + productCodes + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<Product>(sql).ToArray(); } }
public SortOrderDetail[] GetSortOrderDetail(string sortOrders) { string sql = @"SELECT [ORDER_DETAIL_ID] AS OrderDetailID ,[ORDER_ID] AS OrderID ,[BRAND_CODE] AS ProductCode ,[BRAND_NAME] AS ProductName ,['200'] AS UnitCode ,[BRAND_UNIT_NAME] AS UnitName ,[QUANTITY] AS DemandQuantity ,[QUANTITY] AS RealQuantity ,[PRICE] AS Price ,[AMOUNT] AS Amount ,[50] AS UnitQuantity FROM [V_WMS_SORT_ORDER_DETAIL]"; sql = sql + " WHERE ORDER_ID IN('" + sortOrders + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<SortOrderDetail>(sql).ToArray(); } }
public void UpdateWaveApi(List <WaveApi> data) { try { using (var db = new SortingDbContext()) { var waveListOld = data.Select(d => d.WaveNo); var waveList = db.WaveApi.Include("OrderApi").Include("OrderApi.ProductApi").Where(o => waveListOld.Contains(o.WaveNo)); db.WaveApi.RemoveRange(waveList.Where(o => o.Status == WaveStatus.Unwork)); db.SaveChanges(); var ErrorWaveNo = waveList.Where(o => o.Status != WaveStatus.Unwork).Select(o => o.WaveNo).ToList(); db.WaveApi.AddOrUpdate(data.Where(o => !ErrorWaveNo.Contains(o.WaveNo)).ToArray()); bool isSuccess = db.SaveChanges() > 0; Debug.Write(isSuccess); } }catch (Exception ex) { Console.Write(ex.Message); } }
public SortOrderDetail[] GetSortOrderDetail(string sortOrders) { string sql = @"SELECT [ORDER_DETAIL_ID] AS OrderDetailID ,[ORDER_ID] AS OrderID ,[BRAND_CODE] AS ProductCode ,[BRAND_NAME] AS ProductName ,['200'] AS UnitCode ,[BRAND_UNIT_NAME] AS UnitName ,[QUANTITY] AS DemandQuantity ,[QUANTITY] AS RealQuantity ,[PRICE] AS Price ,[AMOUNT] AS Amount ,[50] AS UnitQuantity FROM [V_WMS_SORT_ORDER_DETAIL]"; sql = sql + " WHERE ORDER_ID IN('" + sortOrders + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return(sortdb.Database.SqlQuery <SortOrderDetail>(sql).ToArray()); } }
private void btnPrint_Click(object sender, EventArgs e) { string waveNo = txtWaveNo.Text.Trim(); if (string.IsNullOrWhiteSpace(waveNo)) { MessageBox.Show("请输入所需打印的波次号"); return; } using (var db = new SortingDbContext()) { var result = from wave in db.WaveApi from order in wave.OrderApi from product in order.ProductApi where wave.WaveNo == waveNo && order.Status == Domain.Models.OrderStatus.Normal select new { WaveNo = wave.WaveNo, BarCode = product.BarCode }; if (result.Count() > 0) { new CustomPrint().PrintSetup(new LatticeInfo { OrderNo = result.FirstOrDefault().WaveNo, LatticeNo = "波次号" }); } result.ToList().ForEach(o => { new CustomPrint().PrintSetup(new LatticeInfo { OrderNo = o.BarCode }); }); } }
public UnitList[] GetUnitList(string unitLists) { string sql = @"SELECT [BRAND_ULIST_CODE] AS UnitListCode ,[N_BRAND_ULIST_CODE] AS UniformCode ,[BRAND_ULIST_NAME] AS UnitListName ,[BRAND_UNIT_CODE_01] AS UnitCode01 ,[BRAND_UNIT_NAME_01] AS UnitName01 ,[QTY_01] AS Quantity01 ,[BRAND_UNIT_CODE_02] AS UnitCode02 ,[BRAND_UNIT_NAME_02] AS UnitName02 ,[QTY_02] AS Quantity02 ,[BRAND_UNIT_CODE_03] AS UnitCode03 ,[BRAND_UNIT_NAME_03] AS UnitName03 ,[QTY_03] AS Quantity03 ,[BRAND_UNIT_CODE_04] AS UnitCode04 ,[BRAND_UNIT_NAME_04] AS UnitName04 ,[ISACTIVE] AS IsActive ,getdate() AS UpdateTime FROM [V_WMS_BRAND_ULIST]"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<UnitList>(sql).ToArray(); } }
public Customer[] GetCustomer(string customers) { string sql = @"SELECT [CUST_CODE] AS CustomerCode ,[CUST_N] AS CustomCode ,[CUST_NAME] AS CustomerName ,[ORG_CODE] AS CompanyCode ,[SALE_REG_CODE] AS SaleRegionCode ,[N_CUST_CODE] AS UniformCode ,[CUST_TYPE] AS CustomerType ,[sale_scope] AS SaleScope ,[RTL_CUST_TYPE_CODE] AS IndustryType ,[CUST_GEO_TYPE_CODE] AS CityOrCountryside ,[DELIVER_LINE_CODE] AS DeliverLineCode ,[DELIVER_ORDER] AS DeliverOrder ,[DIST_ADDRESS] AS Address ,[DIST_PHONE] AS Phone ,[LICENSE_TYPE] AS LicenseType ,[LICENSE_CODE] AS LicenseCode ,[PRINCIPAL_NAME] AS PrincipalName ,[PRINCIPAL_TEL] AS PrincipalPhone ,[PRINCIPAL_ADDRESS] AS PrincipalAddress ,[MANAGEMENT_NAME] AS ManagementName ,[MANAGEMENT_TEL] AS ManagementPhone ,[BANK] AS Bank ,[BANK_ACCOUNTS] AS BankAccounts ,[''] AS Description ,[ISACTIVE] AS IsActive ,[UPDATE_DATE] AS UpdateTime FROM [V_WMS_CUSTOMER]"; sql = sql + " WHERE CUST_CODE NOT IN('" + customers + "')"; using (SortingDbContext sortdb = new SortingDbContext()) { return sortdb.Database.SqlQuery<Customer>(sql).ToArray(); } }