示例#1
0
        private void LoadData()
        {
            Guid parnetId;

            if (Guid.TryParse(combStandard.SelectedValue.ToString(), out parnetId))
            {
                List <DsMaterial> materialList = new List <DsMaterial>();
                foreach (View_FormulaStandardDetailModel model in formulaStandardDAL.GetListByParnetId(parnetId))
                {
                    DsMaterial dsMaterial = new DsMaterial();
                    dsMaterial.MaterialId       = model.MatId.ToString();
                    dsMaterial.MaterialName     = model.MatName;
                    dsMaterial.MaterialCode     = model.MatCode;
                    dsMaterial.MaterialQuantity = model.MatQuantity.Value;
                    dsMaterial.Price            = model.Price.Value;
                    dsMaterial.Unit             = model.Unit;
                    materialList.Add(dsMaterial);
                }
                bindingSource.DataSource = materialList;
                dataView1.DataSource     = bindingSource;
                DSW_FormulaStandardModel standardModel = standardModelList.SingleOrDefault(s => s.Id == parnetId);
                IsChecked = standardModel.IsManualFeed;
            }
        }
示例#2
0
        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("添加到队列失败");
            }
        }