public static void RecordAdd(int dsType, string barCode, string potCode, DsRecord dsRecord, DsMaterial dsMaterial) { View_DeviceInfoModel viewModel = deviceDAL.GetDeviceInfoByPotCode(potCode); DS_RecordModel recordModel = new DS_RecordModel(); recordModel.DSType = dsType; recordModel.Action = dsRecord.ActionName; recordModel.BarCode = barCode; recordModel.MatId = new Guid(dsMaterial.MaterialId); recordModel.MatCode = dsMaterial.MaterialCode; recordModel.MatName = dsMaterial.MaterialName; recordModel.DSQuantity = dsMaterial.MaterialQuantity; recordModel.RealQuantity = dsRecord.DSQuantity; recordModel.UnitType = dsMaterial.Unit; recordModel.UnitPrice = dsMaterial.Price; recordModel.TotalPrice = recordModel.RealQuantity * recordModel.UnitPrice; recordModel.DeviceId = viewModel.DeviceId; recordModel.DeviceName = viewModel.DeviceName; recordModel.PotCode = viewModel.PotCode; recordModel.PotName = viewModel.PotName; recordModel.EntryDate = DateTime.Now; recordModel.EntryFilterYMD = DateTime.Now.ToString("yyyyMMdd"); recordDAL.Add(recordModel); }
private void LoadStandardQuantity() { View_DeviceInfoModel model = deviceInfoModelList.SingleOrDefault(s => s.PotCode == comboPot.SelectedValue.ToString()); if (model != null) { lblStandardQuantity.Text = model.StandardQuantity.ToString(); } }
private void btnSure_Click(object sender, EventArgs e) { //if (combStandard.Text == "请选择") //{ // MessageBox.ShowTip("请选择标准配方"); return; //} //if (comboDevice.Text == "请选择") //{ // MessageBox.ShowTip("请选择机台"); return; //} View_DeviceInfoModel deviceModel = deviceInfoModelList.SingleOrDefault(s => s.PotCode == comboPot.SelectedValue.ToString()); View_FormulaInfoModel formulaDetailModel = new View_FormulaInfoModel(); DSW_FormulaStandardModel standardModel = standardModelList.SingleOrDefault(s => s.Id == new Guid(combStandard.SelectedValue.ToString())); formulaDetailModel.Id = Guid.NewGuid(); formulaDetailModel.BarCode = DateTime.Now.ToString("yyMMddHHmmss"); formulaDetailModel.Quantity = decimal.Parse(lblStandardQuantity.Text); formulaDetailModel.StandardQuantity = decimal.Parse(lblStandardQuantity.Text); formulaDetailModel.CylinderNum = 1; formulaDetailModel.DeviceId = deviceModel.DeviceId; formulaDetailModel.DeviceName = deviceModel.DeviceName; formulaDetailModel.DeviceType = deviceModel.Type; formulaDetailModel.PotCode = deviceModel.PotCode; formulaDetailModel.IsManualFeed = IsChecked; formulaDetailModel.Remark = standardModel.Remark; formulaDetailModel.ManufactureOrderId = Guid.Empty; formulaDetailModel.FormulaName = "手动配送"; formulaDetailModel.ManufactureOrderCode = "***"; formulaDetailModel.Customer = "***";; formulaDetailModel.Color = "***"; formulaDetailModel.ProductName = "***"; formulaDetailModel.ProductSpecification = "***"; formulaDetailModel.ProductWidth = "***"; formulaDetailModel.Meter = "***"; formulaDetailModel.LatestDate = DateTime.Now.AddYears(1); formulaDetailModel.Status = 0; formulaDetailModel.ClientIP = deviceModel.IP; formulaDetailModel.CompleteCylinderNum = 0; List <View_FormulaDetailInfoModel> list = new List <View_FormulaDetailInfoModel>(); for (int i = 0; i < dataView1.Rows.Count; i++) { DataGridViewRow dgvr = dataView1.Rows[i]; View_FormulaDetailInfoModel detailInfoModel = new View_FormulaDetailInfoModel(); detailInfoModel.Id = Guid.NewGuid(); detailInfoModel.BarCode = formulaDetailModel.BarCode; detailInfoModel.MaterialId = new Guid(dgvr.Cells["MaterialId"].Value.ToString()); detailInfoModel.MaterialName = dgvr.Cells["MaterialName"].Value.ToString(); detailInfoModel.MaterialCode = dgvr.Cells["MaterialCode"].Value.ToString(); detailInfoModel.MaterialQuantity = decimal.Parse(dgvr.Cells["MaterialQuantity"].Value.ToString()); detailInfoModel.Sort = i; detailInfoModel.Unit = dgvr.Cells["Unit"].Value.ToString(); detailInfoModel.Price = decimal.Parse(dgvr.Cells["Price"].Value.ToString()); detailInfoModel.DeviceId = deviceModel.Id; list.Add(detailInfoModel); } formulaDetailModel.list = list; if (formulaDetailModel.list.Count == 0) { MessageBox.ShowTip("请先添加助剂"); return; } decimal materialSum = list.Sum(s => s.MaterialQuantity); decimal minStandardQuantity = Golbal.CleanWater + Golbal.IntervalWater * dataView1.RowCount + materialSum; decimal maxStandardQuantity = deviceModel.StandardQuantity.Value; if (decimal.Parse(lblStandardQuantity.Text) < minStandardQuantity) { MessageBox.ShowTip("机台缸量不能小于" + minStandardQuantity + ""); return; } if (decimal.Parse(lblStandardQuantity.Text) > maxStandardQuantity) { MessageBox.ShowTip("机台缸量不能大于" + maxStandardQuantity + ""); return; } try { Golbal.MyQueueList.Add(formulaDetailModel); MessageBox.ShowTip("添加到队列成功"); } catch { MessageBox.ShowTip("添加到队列失败"); } }