public void AddReagentAndSupplies(ReagentAndSupply reagentAndSupply) { using (WanTaiEntities entities = new WanTaiEntities()) { entities.ReagentAndSupplies.AddObject(reagentAndSupply); entities.SaveChanges(); } }
public ReagentAndSuppliesList(Guid experimentID) { InitializeComponent(); reagentConfigController = new ReagentSuppliesConfigurationController(); reagentController = new ReagentAndSuppliesController(); DataTable dt = new DataTable(); dt.Columns.Add("BarCode", typeof(string)); dt.Columns.Add("DisplayName", typeof(string)); dt.Columns.Add("Volume", typeof(double)); dt.Columns.Add("Unit", typeof(string)); dt.Columns.Add("ItemType", typeof(string)); List <ReagentAndSuppliesConfiguration> reagentConfigs = reagentConfigController.GetAll(); reagentConfigController.UpdateExperimentVolume(experimentID, ref reagentConfigs, new short[] { ConsumptionType.consume }, ReagentAndSuppliesConfiguration.CurrentVolumeFieldName); reagentConfigController.UpdateExperimentVolume(experimentID, ref reagentConfigs, new short[] { ConsumptionType.Need }, ReagentAndSuppliesConfiguration.NeedVolumeFieldName); List <ReagentAndSupply> reagents = reagentController.GetAll(experimentID); List <DataModel.Configuration.ReagentSuppliesType> reagentType = Common.Configuration.GetReagentSuppliesTypes(); foreach (ReagentAndSuppliesConfiguration r in reagentConfigs) { string itemTypeName = string.Empty; string barCode = string.Empty; DataModel.Configuration.ReagentSuppliesType rType = reagentType.FirstOrDefault(P => P.TypeId == r.ItemType.ToString()); if (rType != null) { itemTypeName = rType.TypeName; } ReagentAndSupply reagent = reagents.FirstOrDefault(P => P.ConfigurationItemID == r.ItemID); if (reagent != null) { barCode = reagent.BarCode; } if (r.ItemType == 104 || r.ItemType == 105) { dt.Rows.Add(barCode, r.DisplayName, Math.Abs(r.CurrentVolume), r.Unit, itemTypeName); } else { dt.Rows.Add(barCode, r.DisplayName, Math.Abs(r.CurrentVolume), r.Unit, itemTypeName); } } dgReagentSupplies.DataContext = dt.DefaultView; }
public Guid GetReagentID(Guid experimentID, string barcodePrefix) { Guid reagentID = Guid.Empty; using (WanTaiEntities entities = new WanTaiEntities()) { ReagentAndSupply reagent = entities.ReagentAndSupplies.FirstOrDefault( P => (P.ExperimentID == experimentID && P.BarCode.StartsWith(barcodePrefix))); if (reagent != null) { reagentID = reagent.ItemID; } } return(reagentID); }
/// <summary> /// 每个操作完成调用此方法添加耗材消耗量 /// </summary> /// <param name="rotationID"></param> /// <param name="operationID"></param> public void AddSuppliesConsumption(Guid rotationID, Guid operationID, FormulaParameters formulaParameters) { Dictionary <short, bool> operation = new OperationController().GetOperationOrders(operationID); List <ReagentAndSuppliesConfiguration> suppliseConfig = reagentConfigController.GetAll().FindAll(P => P.ItemType >= 100 && P.ItemType < 200); List <ReagentAndSupply> supplise = reagentController.GetReagentID(rotationID).FindAll(P => P.ItemType >= 100 && P.ItemType < 200); foreach (ReagentAndSuppliesConfiguration supplyconfig in suppliseConfig) { ReagentAndSupply supply = supplise.FirstOrDefault(P => P.ConfigurationItemID == supplyconfig.ItemID); if (supply != null) { Guid supplyID = supply.ItemID; double consumption = reagentConfigController.CalcVolume(supplyconfig.CalculationFormula, operation, formulaParameters); reagentConsumptionController.AddConsumption(rotationID, supplyID, 0 - consumption, ConsumptionType.consume); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { //MessageBoxResult msResult = MessageBox.Show("确认保存么", "系统提示", MessageBoxButton.YesNo, MessageBoxImage.Information); //if (msResult == MessageBoxResult.No) //{ // return; //} ReagentsAndSuppliesConsumptionController consumptionController = new ReagentsAndSuppliesConsumptionController(); ReagentAndSuppliesController reagentController = new ReagentAndSuppliesController(); PlateController plateController = new PlateController(); foreach (PlateBase plate in ViewPlates) { if (plate.ItemType == 101 && (plate.DisplayName.EndsWith("1") || plate.DisplayName.EndsWith("2"))) { string plateName = ""; if (plate.DisplayName.EndsWith("1")) { plateName = PlateName.DWPlate1; } if (plate.DisplayName.EndsWith("2")) { plateName = PlateName.DWPlate2; } plateController.UpdateBarcode(plateName, 0, SessionInfo.PraperRotation.RotationID, plate.Barcode); } ReagentAndSupply reagent = new ReagentAndSupply(); if ((isFirstRotation) || (!isFirstRotation && (plate.ItemType >= 100 && plate.ItemType < 200))) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } else { reagent.ItemID = new ReagentAndSuppliesController().GetReagentID(SessionInfo.ExperimentID, plate.BarcodePrefix); if (reagent.ItemID == Guid.Empty) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } } ReagentsAndSuppliesConsumption calcReagentConsumption = new ReagentsAndSuppliesConsumption(); calcReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); if (plate.ActualSavedVolume > 0) { calcReagentConsumption.Volume = plate.ActualSavedVolume; } else { calcReagentConsumption.Volume = plate.NeedVolume; } calcReagentConsumption.UpdateTime = DateTime.Now; calcReagentConsumption.ExperimentID = SessionInfo.ExperimentID; calcReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; calcReagentConsumption.VolumeType = ConsumptionType.Need; calcReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(calcReagentConsumption); ReagentsAndSuppliesConsumption scanReagentConsumption = new ReagentsAndSuppliesConsumption(); scanReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); scanReagentConsumption.UpdateTime = DateTime.Now; scanReagentConsumption.ExperimentID = SessionInfo.ExperimentID; scanReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; scanReagentConsumption.VolumeType = ConsumptionType.FirstAdd; if (reagent.ItemType == DiTiType.DiTi200 || reagent.ItemType == DiTiType.DiTi1000) { scanReagentConsumption.Volume = plate.FirstAddVolume * 96; } else { scanReagentConsumption.Volume = plate.FirstAddVolume; } scanReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(scanReagentConsumption); } btnScan.IsEnabled = false; btnManual.IsEnabled = false; btnSave.IsEnabled = false; btnNext.IsEnabled = true; btnSupplies.IsEnabled = false; btnReagent.IsEnabled = false; btnTestItem.IsEnabled = false; SessionInfo.NextButIndex = 3; ////MessageBox.Show("保存成功!", "系统提示"); }
private void WhenAdd() { //DataGrid AddColumns(dtReagent); ReagentSuppliesConfigurationController configurationController = new ReagentSuppliesConfigurationController(); List <ReagentAndSuppliesConfiguration> configurations = configurationController.GetAllActived().Where(P => P.ItemType < 100).OrderBy(P => P.ItemType).ToList(); configurationController.UpdateExperimentVolume(SessionInfo.ExperimentID, ref configurations, new short[] { ConsumptionType.consume, ConsumptionType.Add, ConsumptionType.FirstAdd }, ReagentAndSuppliesConfiguration.CurrentVolumeFieldName); //configurationController.UpdateExperimentVolume(SessionInfo.ExperimentID, ref configurations, new short[] { // ConsumptionType.Need }, ReagentAndSuppliesConfiguration.NeedVolumeFieldName); configurationController.NeededVolumeofProcessingRotations(ref configurations); List <ReagentAndSupply> reagents = new ReagentAndSuppliesController().GetAll(SessionInfo.ExperimentID); foreach (ReagentAndSuppliesConfiguration config in configurations) { if (config.ItemType >= 100) { continue; } Guid?reagentAndSuppplieID = null; config.Correct = config.Correct = config.NeedVolume == 0 ? true : config.CurrentVolume > config.NeedVolume * Common.Configuration.GetMinVolume(); ReagentAndSupply reagent = reagents.FirstOrDefault(P => P.ConfigurationItemID == config.ItemID); if (reagent != null) { reagentAndSuppplieID = reagent.ItemID; } dtReagent.Rows.Add(config.DisplayName, config.CurrentVolume, 0, config.Unit, config.Correct, config.ItemType, reagentAndSuppplieID, config.NeedVolume, config.NeedVolume * Common.Configuration.GetMinVolume(), config.ItemID); } dtReagent.DefaultView.Sort = "ItemType"; dgReagent.DataContext = dtReagent.DefaultView.FindRows(0); foreach (short dataGridKey in dataGridDictionary.Keys) { dataGridDictionary[dataGridKey].ItemsSource = dtReagent.DefaultView.FindRows(dataGridKey); } //Drawing Plates and Carriers viewPlates = new Services.DeskTopService().SetReagentPosition(configurations, new CarrierController().GetCarrier(), 0); double lengthUnit = (this.Width - 50) / 84; double cooPoint = 1.4; panelDeskTop.Width = (this.Width - 50); panelDeskTop.Height = lengthUnit * 30; View.Services.DeskTopService desktopService = new Services.DeskTopService(); carrierBases = desktopService.GetCarriers(lengthUnit, cooPoint); foreach (CarrierBase carrier in carrierBases) { carrier.UpdatePlate(viewPlates.FindAll(P => P.ContainerName == carrier.CarrierName)); panelDeskTop.Children.Add(carrier); } panelDeskTop.Children.Add(desktopService.DrawCoordinate((this.Width - 50), 69, lengthUnit)); for (int i = 0; i < dtReagent.Rows.Count; i++) { if (!(bool)dtReagent.Rows[i]["Correct"]) { this.btnSave.Visibility = System.Windows.Visibility.Visible; } } }