public List<StockDetail> ImportToXls(string fileName, ref string ErrMsg) { List<StockDetail> list = new List<StockDetail>(); try { using (var file = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite)) { string strExt = System.IO.Path.GetExtension(fileName); IWorkbook wb;// = new XSSFWorkbook(file); if (strExt.Equals(".xls")) { wb = new HSSFWorkbook(file); } else wb = new XSSFWorkbook(file); ISheet sheet = wb.GetSheetAt(0); for (int i = 0; i <= sheet.LastRowNum; i++) { try { IRow row = sheet.GetRow(i); for (int j = 0; j < 1; j++) { ICell readCell = row.GetCell(j); StockDetail glass = new StockDetail(); glass.GlassID = readCell.ToString().ToUpper(); readCell.ToString();//这就是当前格子的值了 glass.Qty = 1; glass.AccountID = CurrentAccount.ID; glass.AccountName = CurrentAccount.Name; glass.Status = 0; glass.CreateDt = DateTime.Now; if (list.Any(p => p.GlassID.Equals(glass.GlassID))) { ErrMsg = "Excel中存在重复的GlassID"; return null; } list.Add(glass); } } catch { } } } } catch (Exception ex) { ErrMsg = ex.Message; } if (list.Count() <= 0) { ErrMsg = "当前不存在需要导入的GlassID,请检查Excel格式"; } return list; }
private void Form_Closed(object sender, FormClosedEventArgs e) { if (transferList == null) { return; } var demandMaster = dbContext.ItemDemandMaster.Find(_itemDemandMasterId); foreach (var item in transferList) { var existStockDetail = StockHelper.GetBarcodeStocks(item.BarcodeId); var stockDetail = new StockDetail(); stockDetail.STOCKDETAIL_BARCODE_ID = item.BarcodeId; stockDetail.STOCKDETAIL_MASTER_ID = _stockMasterId; stockDetail.STOCKDETAIL_STORE_ID = existStockDetail.STOCKDETAIL_STORE_ID; stockDetail.STOCKDETAIL_ITEM_ID = existStockDetail.STOCKDETAIL_ITEM_ID; stockDetail.STOCKDETAIL_RACK_ID = existStockDetail.STOCKDETAIL_RACK_ID; stockDetail.STOCKDETAIL_QUANTITY = Convert.ToDouble(item.Quantity) * -1; dbContext.StockDetail.Add(stockDetail); dbContext.SaveChanges(); var stockDetailSecond = new StockDetail(); stockDetailSecond.STOCKDETAIL_BARCODE_ID = item.BarcodeId; stockDetailSecond.STOCKDETAIL_MASTER_ID = _stockMasterId; stockDetailSecond.STOCKDETAIL_STORE_ID = demandMaster.Project.Company.COMPANY_STORE_ID.Value; stockDetailSecond.STOCKDETAIL_ITEM_ID = existStockDetail.STOCKDETAIL_ITEM_ID; stockDetailSecond.STOCKDETAIL_RACK_ID = existStockDetail.STOCKDETAIL_RACK_ID; stockDetailSecond.STOCKDETAIL_QUANTITY = Convert.ToDouble(item.Quantity); stockDetailSecond.STOCKDETAIL_REF_ID = stockDetail.ID; dbContext.StockDetail.Add(stockDetailSecond); dbContext.SaveChanges(); } LoadData(); transferList.Clear(); }
private void btnSubmit_Click(object sender, EventArgs e) { int serviceId = 0; int.TryParse(txtServiceId.Text, out serviceId); var serviceObj = new Service { Id = serviceId, Name = txtName.Text, Type = (cmbType.SelectedItem as ServiceType).Id, Cost = Convert.ToDouble(txtCost.Text), Status = Convert.ToSByte(chkStatus.Checked), CreatedOn = DateTime.Now, CreeatedBy = App.LoggedInEmployee.Id, ModifiedOn = DateTime.Now, ModifiedBy = App.LoggedInEmployee.Id, AllowMultiple = Convert.ToSByte(chkAllowMultiple.Checked) }; var serviceDao = new ServiceDao(); int scid = serviceDao.SavePrintSeries(serviceObj); if (serviceId == 0) { var sdDao = new StockDetailsDao(); var sdObj = new StockDetail { ServiceId = scid, Stock = 0 }; sdDao.SaveStockDetail(sdObj); } ShowServices(); }
public bool UpdateProductDetails(long productId, string productName, decimal quantity, decimal buyingPrice, decimal retailPrice, decimal wholesalePrice, decimal creditPrice, int gstPercentage) { bool isProductDetailsUpdated = false; using (Billing_Customized_Entities updateProductDetails = new Billing_Customized_Entities()) { StockDetail stock = updateProductDetails.StockDetails.FirstOrDefault(obj => obj.ProductId == productId); if (stock != null) { stock.ProductName = productName; stock.Quantity = quantity; stock.BuyingPrice = Math.Round(buyingPrice, 2); stock.RetailPrice = Math.Round(retailPrice, 2); stock.WholesalePrice = Math.Round(wholesalePrice, 2); stock.CreditPrice = Math.Round(creditPrice, 2); stock.GSTPercentage = gstPercentage; isProductDetailsUpdated = true; updateProductDetails.SaveChanges(); } return(isProductDetailsUpdated); } }
public void SaveStockDetail(StockDetail stObj) { using (var db = new eTempleDbDB()) { db.Save(stObj); } }
public StockDetail GetStockDetailByBatchNo(string batchNo) { StockDetail stockDetail = new StockDetail(); stockDetail = Database.StockDetails.Single(sd => sd.BatchNo == batchNo && sd.StockMaster.StockTransactionTypeID == Convert.ToInt32(EnumCollection.StockTransactionType.Purchase)); return(stockDetail); }
public async Task <IActionResult> PutStockDetail([FromRoute] int id, [FromBody] StockDetail stockDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stockDetail.ItemId) { return(BadRequest()); } _context.Entry(stockDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void baseAddEditMasterDetail_saveHandler() { StockDetail entity = this.GetDetailData(); try { this.ValidationDetail(entity); string adjust = string.Format(Format.DecimalNumberFormat, txtAdjust.Text.ToDecimal()); if (baseGridDetail.FormMode == ObjectState.Edit) { DataRow dr = this.GetDataRowDetail(baseGridDetail.DataKeyValue[1].ToLong(), baseGridDetail.DataKeyValue[2].ToDecimal()).First(); dr["Adjust"] = adjust; dr["Remark"] = txtRemarkDetails.Text; } this.ClearDataDetail(); txtAdjust.Focus(); baseGridDetail.FormMode = ObjectState.Add; baseGridDetail.DataKeyValue = null; this.EnableModeDetail(); } catch (ValidationException ex) { throw ex; } }
private StockDetail BuildStockDetail(Data.Entities.StockDetail detail) { var myDetail = new StockDetail(); using (_unitOfWork) { if (_products == null) { _products = new List <Product>(); foreach (var product in _unitOfWork.Products.Find()) { _products.Add(Mapper.Map <Product>(product)); } } var p = _products.SingleOrDefault(x => x.Id == detail.ProductId); if (p != null) { myDetail.Id = detail.Id; myDetail.ProductId = p.Id; myDetail.Quantity = detail.Quantity; myDetail.Price = detail.Price; myDetail.StockId = detail.StockId; myDetail.Product = p; } } return(myDetail); }
public ReturnType AddStockDetail(StockDetail stockdetail) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { alading.AddToStockDetail(stockdetail); if (alading.SaveChanges() == 1) { return(ReturnType.Success); } else { return(ReturnType.PropertyExisted); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
public ReturnType RemoveStockDetail(string stockdetailCode) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*List<StockDetail> list = alading.StockDetail.Where(p => p.StockDetailID == stockdetailID).ToList();*/ List <StockDetail> list = alading.StockDetail.Where(p => p.StockDetailCode == stockdetailCode).ToList(); if (list.Count == 0) { return(ReturnType.NotExisted); } else { StockDetail sy = list.First(); alading.DeleteObject(sy); alading.SaveChanges(); return(ReturnType.Success); } } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (System.Exception ex) { return(ReturnType.OthersError); } }
public void Dispose() { if (playerService != null) { playerService.Dispose(); playerService = null; } if (aiEntities != null) { aiEntities.Dispose(); aiEntities = null; } if (shouldSell != null) { shouldSell = null; } if (shouldBuy != null) { shouldBuy = null; } if (curGame != null) { curGame = null; } if (list != null) { list = null; } }
public void CheckHistoryForSell(List <TurnDetail> prevTurns, List <StockDetail> currentStocks) { //shouldSell = new StockDetail(); //List<TurnDetail> prevTurns = prevTurnsArray.Cast<TurnDetail>().ToList(); foreach (TurnDetail turn in prevTurns) { foreach (SectorDetail sector in turn.Sectors) { foreach (StockDetail stock in sector.Stocks) { foreach (StockDetail owned in currentStocks) { if (stock.StockId != owned.StockId) { continue; } else { if (shouldSell == null) { shouldSell = stock; } else if (shouldSell.CurrentPrice < stock.CurrentPrice) { shouldSell = stock; } } } } } } }
/// <summary> /// 添加 /// </summary> /// <param name="dep"></param> /// <returns></returns> public static int AddStockDetail(StockDetail dep) { PSSEntities db = new PSSEntities(); db.StockDetail.Add(dep); return(db.SaveChanges()); }
private void grdItems_MouseDoubleClick(object sender, MouseEventArgs e) { try { int[] selRows = ((GridView)grdItems.MainView).GetSelectedRows(); DataRowView oStockID = (DataRowView)(((GridView)grdItems.MainView).GetRow(selRows[0])); int nStockID = Convert.ToInt32(oStockID["ID"]); StockDetail oStockDetail = db.StockDetails.FirstOrDefault(p => p.SDetailID == nStockID); if (oStockDetail != null) { _ctl.SelectedID = oStockDetail.SDetailID; _ctl.Code = oStockDetail.Product.ProductName; _ctl.Name = oStockDetail.IMENO; } if (ItemChanged != null) { ItemChanged(); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AddingDataIntoTextboxesAfterProductSelection(string selectedProductId) { StockDetail selectedProduct = availableProducts.FirstOrDefault(obj => obj.ProductId.ToString().Equals(Product_Search_Textbox.Text) || obj.ProductName.Equals(selectedProductId)); if (selectedProduct == null) { return; } Product_Search_Textbox.Text = selectedProduct.ProductId.ToString(); Product_Name_Textbox.Text = selectedProduct.ProductName; Retail_Price_Textbox.Text = string.Format("{0:0.00}", selectedProduct.RetailPrice); Available_Qty_Textbox.Text = string.Format("{0:0.00}", selectedProduct.Quantity); Gst_Percent_Textbox.Text = selectedProduct.GSTPercentage.ToString(); HideResults(); if (selectedProduct.Quantity != 0) { Quantity_textBox.Focus(); Quantity_textBox.ReadOnly = false; } else { if (MessageBox.Show("Selected Product Is Not Available, It's Available Quantity is Zero", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop) == DialogResult.OK) { Product_Search_Textbox.Focus(); Product_Search_Textbox.Text = Product_Name_Textbox.Text = Retail_Price_Textbox.Text = string.Empty; Available_Qty_Textbox.Text = Gst_Percent_Textbox.Text = string.Empty; } } }
/// <summary> /// 修改 /// </summary> /// <param name="dp"></param> /// <returns></returns> public static int EdiStockDetail(StockDetail dp) { PSSEntities db = new PSSEntities(); db.Entry <StockDetail>(dp).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); }
public static Collection <StockDetail> GetStockMasterDetailCollection(string json, int storeId) { Collection <StockDetail> details = new Collection <StockDetail>(); var jss = new JavaScriptSerializer(); dynamic result = jss.Deserialize <dynamic>(json); foreach (dynamic item in result) { StockDetail detail = new StockDetail(); detail.ItemCode = item[0]; detail.Quantity = Conversion.TryCastInteger(item[2]); detail.UnitName = item[3]; detail.Price = Conversion.TryCastDecimal(item[4]); detail.Discount = Conversion.TryCastDecimal(item[6]); detail.ShippingCharge = Conversion.TryCastDecimal(item[7]); detail.TaxForm = item[9]; detail.Tax = Conversion.TryCastDecimal(item[10]); detail.StoreId = storeId; details.Add(detail); } return(details); }
public ResultToken SellStocks(int playerId, StockDetail stock, int quantity, decimal price) { ResultToken result = null; PlayerTransactionsDTO obj = new PlayerTransactionsDTO(); obj.PlayerId = playerId; obj.Stock = stock; obj.Quantity = quantity; obj.Price = price; try { using (APIService apiClient = new APIService()) { var temp = apiClient.MakePostRequest("api/Broker/SellStocks", obj); result = apiClient.ConvertObjectToToken(temp); if (result != null && result.Success) { result.Data = obj; } } } catch (Exception ex) { Logger logger = LogManager.GetLogger("excpLogger"); logger.Error(ex); } return(result); }
public ReturnType UpdateStockDetail(StockDetail stockdetail) { try { using (AladingEntities alading = new AladingEntities(AppSettings.GetConnectionString())) { /*StockDetail result = alading.StockDetail.Where(p => p.StockDetailID == stockdetail.StockDetailID).FirstOrDefault();*/ StockDetail result = alading.StockDetail.Where(p => p.StockDetailCode == stockdetail.StockDetailCode).FirstOrDefault(); if (result == null) { return(ReturnType.NotExisted); } #region Using Attach() Function Update,Default USE; alading.Attach(result); alading.ApplyPropertyChanges("StockDetail", stockdetail); #endregion #region Using All Items Replace To Update ,Default UnUse /* * * result.StockDetailCode = stockdetail.StockDetailCode; * * result.ProductSkuOuterId = stockdetail.ProductSkuOuterId; * * result.InOutCode = stockdetail.InOutCode; * * result.StockHouseCode = stockdetail.StockHouseCode; * * result.Price = stockdetail.Price; * * result.Quantity = stockdetail.Quantity; * * result.DetailType = stockdetail.DetailType; * * result.TaxFee = stockdetail.TaxFee; * * result.TotalFee = stockdetail.TotalFee; * * result.DetailRemark = stockdetail.DetailRemark; * */ #endregion if (alading.SaveChanges() == 1) { return(ReturnType.Success); } return(ReturnType.OthersError); } } catch (SqlException sex) { return(ReturnType.ConnFailed); } catch (Exception ex) { return(ReturnType.OthersError); } }
// GET: Stock/Delete/5 public ActionResult Delete(StockDetail IdToDel) { var d = Entities_MVC.StockDetails.Where(x => x.id == IdToDel.id).FirstOrDefault(); Entities_MVC.StockDetails.Remove(d); Entities_MVC.SaveChanges(); return(RedirectToAction("AllStock")); }
public StockDetail GetStockDetailByID(long id) { StockDetail stockDetail = new StockDetail(); stockDetail = Database.StockDetails.Single(s => s.IID == id && s.IsRemoved == 0); stockDetail.Item = stockDetail.Item; return(stockDetail); }
public ActionResult DeleteConfirmed(int id) { StockDetail stockDetail = db.StockDetails.Find(id); db.StockDetails.Remove(stockDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool SaveProduct(StockDetail newStock) { using (Store_BillingEntities saveProductDetails = new Store_BillingEntities()) { saveProductDetails.StockDetails.Add(newStock); saveProductDetails.SaveChanges(); return(true); } }
private void OnProductRemoveFromCartCommand(StockDetail stockDetail) { var details = Stock.Details; details.RemoveAt(details.IndexOf(details.FirstOrDefault(x => x.ProductId == stockDetail.ProductId))); Products.Add(stockDetail.Product); Stock.Quantity -= stockDetail.Quantity; Stock.TotalPrice -= (decimal)stockDetail.Quantity * stockDetail.Price; }
public ActionResult Update(Guid id) { StockDetail sd = sds.GetByID(id); ViewBag.DealerID = new SelectList(ds.GetActive(), "ID", "Name", sd.DealerID); ViewBag.BookID = new SelectList(bs.GetActive(), "ID", "Title", sd.BookID); return(View(sd)); }
private void btnSave_Click(object sender, EventArgs e) { int targetStore = (int)lueTargetStore.EditValue; int sourceStore = (int)lueSourceStore.EditValue; string stockDetail = (string)lueStockDetail.EditValue; double quantity = Convert.ToDouble(txtQuantity.EditValue == "" ? 0 : txtQuantity.EditValue); if (_stockDetailId == 0) { var selectedStock = StockHelper.GetBarcodeStocks(stockDetail); StockDetail entryDetail = new StockDetail() { STOCKDETAIL_ITEM_ID = selectedStock.STOCKDETAIL_ITEM_ID, STOCKDETAIL_RACK_ID = selectedStock.STOCKDETAIL_RACK_ID, STOCKDETAIL_BARCODE_ID = selectedStock.STOCKDETAIL_BARCODE_ID, STOCKDETAIL_STORE_ID = sourceStore, STOCKDETAIL_QUANTITY = quantity, STOCKDETAIL_MASTER_ID = _stockMasterIdEntry, }; dbContext.StockDetail.Add(entryDetail); dbContext.SaveChanges(); dbContext.StockDetail.Add(new StockDetail { STOCKDETAIL_ITEM_ID = selectedStock.STOCKDETAIL_ITEM_ID, STOCKDETAIL_RACK_ID = selectedStock.STOCKDETAIL_RACK_ID, STOCKDETAIL_BARCODE_ID = selectedStock.STOCKDETAIL_BARCODE_ID, STOCKDETAIL_STORE_ID = targetStore, STOCKDETAIL_QUANTITY = quantity * -1, STOCKDETAIL_MASTER_ID = _stockMasterId, STOCKDETAIL_REF_ID = entryDetail.ID, STOCKDETAIL_REF_LINK = "StockDetail" }); } else { StockDetail existStockDetail = dbContext.StockDetail.Find(_stockDetailId); existStockDetail.STOCKDETAIL_ITEM_ID = existStockDetail.STOCKDETAIL_ITEM_ID; existStockDetail.STOCKDETAIL_RACK_ID = existStockDetail.STOCKDETAIL_RACK_ID; existStockDetail.STOCKDETAIL_BARCODE_ID = existStockDetail.STOCKDETAIL_BARCODE_ID; existStockDetail.STOCKDETAIL_STORE_ID = targetStore; existStockDetail.STOCKDETAIL_QUANTITY = quantity; existStockDetail.STOCKDETAIL_MASTER_ID = _stockMasterId; StockDetail existStockDetail2 = dbContext.StockDetail.SingleOrDefault(x => x.ID == existStockDetail.STOCKDETAIL_REF_ID); existStockDetail2.STOCKDETAIL_QUANTITY = quantity * -1; existStockDetail2.STOCKDETAIL_ITEM_ID = existStockDetail.STOCKDETAIL_ITEM_ID; existStockDetail2.STOCKDETAIL_RACK_ID = existStockDetail.STOCKDETAIL_RACK_ID; existStockDetail2.STOCKDETAIL_BARCODE_ID = existStockDetail.STOCKDETAIL_BARCODE_ID; existStockDetail2.STOCKDETAIL_STORE_ID = targetStore; existStockDetail2.STOCKDETAIL_MASTER_ID = _stockMasterId; _stockDetailId = 0; } dbContext.SaveChanges(); lueStockDetail.EditValue = ""; txtQuantity.Text = ""; LoadData(); }
public IAsyncResult BeginAddStockDetail(string checkCode, int AccountID, StockDetail entity, bool IsCheck, ref int QtyCount, ref string ErrMsg, AsyncCallback callback, object asyncState) { IncrementCallCount(); var pCallback = new AsyncCallback((ar) => { DecrementCallCount(); callback(ar); }); return _client.BeginAddStockDetail(checkCode, AccountID, entity, IsCheck, ref QtyCount, ref ErrMsg, pCallback, asyncState); }
private void LoadDataIntoTextBoxesForSelectedProduct(object sender, RunWorkerCompletedEventArgs e) { StockDetail selectedProductDetails = (StockDetail)e.Result; ProductId_textBox.Text = selectedProductDetails.ProductId.ToString(); ProductName_textBox.Text = selectedProductDetails.ProductName; selectedProductPrice = ProductPrice_textBox.Text = selectedProductDetails.Price.ToString(); Description_textbox.Text = selectedProductDetails.ProductDescription; selectedProductQty = Quantity_textBox.Text = selectedProductDetails.QuantityAvailable.ToString(); }
private List <TurnDetail> calculateTurnScore(GameDetailDTO gameDetail) { List <TurnDetail> turnDetails = new List <TurnDetail>(); int[] randomTrend = (int[])gameDetail.RandomTrend; int[] marketTrend = (int[])gameDetail.MarketTrend; Dictionary <int, int>[] sectorTrend = (Dictionary <int, int>[])gameDetail.SectorTrend; EventDetail[] eventTrend = (EventDetail[])gameDetail.EventDetail; var sectors = eventEntities.Sectors.ToList(); for (int i = 0; i < GameDataManager.noOfTurns; i++) { TurnDetail tempTurn = new TurnDetail(); tempTurn.Turn = i + 1; List <SectorDetail> sectoreDetailList = new List <SectorDetail>(); foreach (var st in sectorTrend[i]) { SectorDetail sectoreDetail = new SectorDetail(); var tempSector = sectors.FirstOrDefault(x => x.SectorId == st.Key); sectoreDetail.Sector = Mapping.Mapper.Map <SectorDTO> (tempSector); var value = (st.Value + randomTrend[i] + marketTrend[i] + (((eventTrend[i] != null) && ((eventTrend[i].IsStock) || ((eventTrend[i].IsSector) && (eventTrend[i].SectorId == sectoreDetail.Sector.SectorId)))) ? eventTrend[i].Effect : 0)); sectoreDetail.Score = value < 0?0:value; var stocks = eventEntities.Stocks.Where(a => a.SectorId == sectoreDetail.Sector.SectorId).ToList(); List <StockDetail> stockDetailList = new List <StockDetail>(); foreach (var stock in stocks) { StockDetail stockDetail = new StockDetail(); stockDetail.StockId = stock.StockId; stockDetail.StockName = stock.StockName; if (i == 0) { stockDetail.StartingPrice = stock.StartingPrice; } else { var tempObj = turnDetails.FirstOrDefault(z => z.Turn == i); stockDetail.StartingPrice = tempObj.Sectors.FirstOrDefault(x => x.Sector.SectorId == sectoreDetail.Sector.SectorId).Stocks.FirstOrDefault(y => y.StockId == stockDetail.StockId).CurrentPrice; } stockDetail.CurrentPrice = Decimal.Round(Decimal.Add(stockDetail.StartingPrice, Decimal.Multiply(stockDetail.StartingPrice, Decimal.Divide(sectoreDetail.Score, 100))), 2); stockDetailList.Add(stockDetail); } sectoreDetail.Stocks = new List <StockDetail>(stockDetailList); sectoreDetailList.Add(sectoreDetail); } tempTurn.Sectors = sectoreDetailList; turnDetails.Add(tempTurn); } return(turnDetails); }
public void Upsert(StockDetail stockDetail) { if (_redisClient.ContainsKey(stockDetail.Id)) { _redisClient.Replace(stockDetail.Id, stockDetail); } else { _redisClient.Add(stockDetail.Id, stockDetail); } }
public ActionResult Create(StockDetail NewStock) { if (!ModelState.IsValid) { return(View()); } Entities_MVC.StockDetails.Add(NewStock); Entities_MVC.SaveChanges(); //Response.Redirect("StudentAdmission",true); return(RedirectToAction("AllStock")); }
public ToolScanGlassID_StockInViewModel() { this._eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); this._eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdName) { case CmdName.New: CurrentStockLot = param.Entity as StockLot; if (CurrentStockLot != null) { if (CurrentStockLot.DetailInfoHOLD != null) ControlsEnabled = CurrentStockLot.DetailInfoHOLD.Contains("入库"); else ControlsEnabled = false; _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.New, Entity = CurrentStockLot, Target = "ToolScanGlassID_StockInView", }); } IsHOLD = false; break; case CmdName.SendTag: _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.Close, Target = "ToolScanGlassID_StockInView", }); StockDetail detail = new StockDetail(); detail.IsHOLD = IsHOLD; detail.StockInInfo = param.Tag; _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.SaveGlassID, Entity = detail, Target = "StockInMainViewModel", }); break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "ToolScanGlassID_StockInViewModel"); }
/// <summary> /// 新增GlassID异步 /// </summary> /// <param name="entity">需要新增的实体</param> /// <param name="IsCheck">是否需要对比关键字</param> public void AddStockDetailAsyns(StockDetail entity, bool IsCheck) { int tmpQtyCount = 0; string ErrMsg = string.Empty; entity.AccountID = CurrentAccount.ID; entity.AccountName = CurrentAccount.Name; Proxy.BeginAddStockDetail(CurrentAccount.CheckCode, CurrentAccount.ID, entity, IsCheck, ref tmpQtyCount, ref ErrMsg, result => { ThreadHelper.BeginInvokeOnUIThread(() => { try { bool bResult = Proxy.EndAddStockDetail(ref tmpQtyCount, ref ErrMsg, result); if (bResult) { QtyCount = tmpQtyCount; AddStockDetailCompleted(this, new ResultArgs<bool>(bResult, null, false, result.AsyncState)); } else { AddStockDetailCompleted(this, new ResultArgs<bool>(bResult, new Exception(ErrMsg), true, result.AsyncState)); } } catch (Exception ex) { if (AddStockDetailCompleted != null) { AddStockDetailCompleted(this, new ResultArgs<bool>(false, ex, true, result.AsyncState)); } } }); }, null); }
/// <summary> /// 添加GlassID /// </summary> /// <param name="checkCode"></param> /// <param name="AccountID"></param> /// <param name="entity">新增的实体</param> /// <param name="IsCheck">是否需要对比关键字</param> /// <param name="QtyCount">添加成功之后,带出该LotNO下实际已入库数量</param> /// <param name="ErrMsg"></param> /// <returns></returns> public bool AddStockDetail(string checkCode, int AccountID, StockDetail entity, bool IsCheck, ref int QtyCount, ref string ErrMsg) { throw new NotImplementedException(); }
public bool DeleteStockDetail(string checkCode, int AccountID, StockDetail entity, ref string ErrMsg) { return _client.DeleteStockDetail(checkCode, AccountID, entity, ref ErrMsg); }
public Process_JianBaoViewModel() { _eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>(); //订阅 _eventAggregator.GetEvent<CmdEvent>().Subscribe(param => { switch (param.cmdName) { case CmdName.New: CurrentStockLot = new StockLot(); TXTLOTNOISEnabled = true; ReadComTest(); CountInfo = string.Empty;//统计初始化 Account loginAcount = Common.ServiceDataLocator.GetInstance<Account>(); if (!loginAcount.LoginNumber.Equals("admin")) { HOLDVisibility = Visibility.Collapsed; string roleDetail = loginAcount.Role.RoleDetail; if (roleDetail.Contains(_roleRule.str减薄后检验 + _roleRule.str接触HOLD)) HOLDVisibility = Visibility.Visible; } else { HOLDVisibility = Visibility.Visible; } if (!string.IsNullOrWhiteSpace(param.Tag)) { CurrentStockLot.LotNo = param.Tag; _stockLotRule.GetStockLotEntityByLotNoAsyns(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll); } break; case CmdName.SaveGlassID: SaveEntity = param.Entity as StockDetail; SaveEntity.Status = STATIC_STATUS; _stockLotRule.ModifyStockDetailListAsyns(SaveEntity); // _stockLotRule.UpdateStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, 2); break; default: break; } }, ThreadOption.UIThread, true, p => p.Target == "Process_JianBaoViewModel"); _roleRule = new RoleRule(); _stockLotRule = new StockLotRule(); _stockLotRule.GetStockLotEntityByLotNoCompleted += (s, e) => { if (e.Cancelled || e.Results == null) { Common.MessageBox.Show(e.Error.Message); } else { TXTLOTNOISEnabled = false; _lineNumber = 1; CurrentStockLot = e.Results as StockLot; CurrentStockLot.StockDetails = CurrentStockLot.StockDetails.OrderByDescending(p => p.JianBaoDT).ToArray(); CountInfo = string.Format(" 入库数:{0} PCS HOLD数:{2} 当前已减薄数:{1} PCS", _stockLotRule.StockInQty, _stockLotRule.OperaterQty, _stockLotRule.HOLDQty); _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdName = CmdName.Enter, Target = "Process_JianBaoView", }); } }; _stockLotRule.ModifyStockDetailListCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); } else { List<StockDetail> sd = CurrentStockLot.StockDetails.ToList(); SaveEntity.StockLot = CurrentStockLot; sd.Add(SaveEntity); CurrentStockLot.StockDetails = sd.OrderByDescending(p => p.StockInDT).ToArray(); int StockInQty = 0; int OperaterQty = 0; int FanGongQty = 0; int HOLDQty = 0; string ErrMsg = string.Empty; if (_stockLotRule.GetStockLotEntityByLotNoTotal(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll, ref StockInQty, ref OperaterQty, ref FanGongQty, ref HOLDQty, ref ErrMsg)) CountInfo = string.Format(" 入库数:{0} PCS HOLD数:{2} 当前已减薄数:{1} PCS", StockInQty, OperaterQty, HOLDQty); //_stockLotRule.GetStockLotEntityByLotNoAsyns(CurrentStockLot.LotNo, STATIC_STATUS, IsCheckAll); GlassID = string.Empty; } isDispose = false; }; //验证GlassID方法调用成功后 _stockLotRule.CheckStockDetailStatusCompleted += (s, e) => { if (e.Cancelled) { Common.MessageBox.Show(e.Error.Message); GlassID = string.Empty; isDispose = false; } else { StockDetail entity = e.Results as StockDetail; _eventAggregator.GetEvent<CmdEvent>().Publish(new CmdEventParam() { cmdViewName = CmdViewName.ToolScanGlassID_JianBaoView, Entity = entity, Tag = CurrentStockLot.ImageHOLD, cmdName = CmdName.New, Target = "Sell", }); } }; //修改HOLD成功后回调事件 _stockLotRule.ChangeStockDetail_HOLDCompleted += (s, e) => { bool bHOLD = (bool)e.UserState; if (e.Cancelled) { CurrentDetail.IsHOLD = !bHOLD; Common.MessageBox.Show(e.Error.Message); } else { if (bHOLD) { Common.MessageBox.Show(CurrentDetail.GlassID + " 设置HOLD状态成功"); } else { Common.MessageBox.Show(CurrentDetail.GlassID + " 取消HOLD状态成功"); } } }; ScanComExecute = (s, e) => { GlassID = s.ToString(); _stockLotRule.CheckStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, STATIC_STATUS); // _stockLotRule.UpdateStockDetailStatusAsyns(GlassID, CurrentStockLot.ID, 2);//todo是否验证写死了 // AddStockDetailAsyns(); }; }
/// <summary> /// 修改HOLD状态 /// </summary> /// <param name="entity"></param> public void ChangeStockDetail_HOLDAsyns(StockDetail entity) { string ErrMsg = string.Empty; Proxy.BeginModifyStockDetail(CurrentAccount.CheckCode, CurrentAccount.ID, entity, ref ErrMsg, result => { ThreadHelper.BeginInvokeOnUIThread(() => { try { bool bResult = Proxy.EndModifyStockDetail(ref ErrMsg, result); if (bResult) { ChangeStockDetail_HOLDCompleted(this, new ResultArgs<bool>(bResult, null, false, result.AsyncState)); } else { ChangeStockDetail_HOLDCompleted(this, new ResultArgs<bool>(bResult, new Exception(ErrMsg), true, result.AsyncState)); } } catch (Exception ex) { if (ChangeStockDetail_HOLDCompleted != null) { ChangeStockDetail_HOLDCompleted(this, new ResultArgs<bool>(false, ex, true, result.AsyncState)); } } }); },entity.IsHOLD); }
public void ImportToXlsAsyns(string fileName) { ThreadHelper.BeginInvokeOnUIThread(() => { List<StockDetail> list = new List<StockDetail>(); try { using (var file = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite)) { IWorkbook wb = new XSSFWorkbook(file); ISheet sheet = wb.GetSheetAt(0); for (int i = 0; i < sheet.LastRowNum; i++) { try { IRow row = sheet.GetRow(i); for (int j = 0; j < 1; j++) { ICell readCell = row.GetCell(j); StockDetail glass = new StockDetail(); glass.GlassID = readCell.ToString(); readCell.ToString();//这就是当前格子的值了 list.Add(glass); } } catch { } } } } catch (Exception ex) { if (ImportToXlsCompleted != null) { ImportToXlsCompleted(this, new ResultsArgs<StockDetail>(null, ex, true, null)); } } if (ImportToXlsCompleted != null) { ImportToXlsCompleted(this, new ResultsArgs<StockDetail>(list, null, false, null)); } }); }
private void AddStockDetailAsyns(StockDetail entity) { // StockDetail entity = new StockDetail(); entity.GlassID = GlassID.ToUpper(); entity.Qty = 1; entity.StockLotID = CurrentStockLot.ID; entity.Status = 1; entity.StockInDT = DateTime.Now; // entity.IsHOLD=isHo // entity.AccountID=curren _stockLotRule.AddStockDetailAsyns(entity, IsCheck); }
public bool ModifyStockDetail(string checkCode, int AccountID, StockDetail entity, ref string ErrMsg) { throw new NotImplementedException(); }
public void ModifyStockDetailListAsyns(StockDetail entity) { switch (entity.Status) { case 2://减薄 entity.JianBaoAccountID = CurrentAccount.ID; entity.JianBaoAccountName = CurrentAccount.Name; // entity.DuMoDT = DateTime.Now; break; case 3://抛光 case 8: entity.PaoGuangAccountID = CurrentAccount.ID; if (!IsHouTai) { entity.PaoGuangAccountName += CurrentAccount.Name + ","; } //entity.PaoGuangDT = DateTime.Now; break; case 4://镀膜 entity.DuMoAccountID = CurrentAccount.ID; entity.DuMoAccountName = CurrentAccount.Name; // entity.DuMoDT = DateTime.Now; break; default: break; } string ErrMsg = string.Empty; Proxy.BeginModifyStockDetail(CurrentAccount.CheckCode, CurrentAccount.ID, entity, ref ErrMsg, result => { ThreadHelper.BeginInvokeOnUIThread(() => { try { bool bResult = Proxy.EndModifyStockDetail(ref ErrMsg, result); if (bResult) { ModifyStockDetailListCompleted(this, new ResultArgs<bool>(bResult, null, false, result.AsyncState)); } else { ModifyStockDetailListCompleted(this, new ResultArgs<bool>(bResult, new Exception(ErrMsg), true, result.AsyncState)); } } catch (Exception ex) { if (ModifyStockDetailListCompleted != null) { ModifyStockDetailListCompleted(this, new ResultArgs<bool>(false, ex, true, result.AsyncState)); } } }); }, null); }
public IAsyncResult BeginDeleteStockDetail(string checkCode, int AccountID, StockDetail entity, ref string ErrMsg, AsyncCallback callback, object asyncState) { throw new NotImplementedException(); }
public bool DeleteStockDetail(StockDetail entity, ref string ErrMsg) { return Proxy.DeleteStockDetail(CurrentAccount.CheckCode, CurrentAccount.ID, entity, ref ErrMsg); }