private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } if (dataGridView1.Columns [e.ColumnIndex].Name.Equals("yfNum", StringComparison.OrdinalIgnoreCase) == true || dataGridView1.Columns [e.ColumnIndex].Name.Equals("yfPrice", StringComparison.OrdinalIgnoreCase) == true) { _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); if (dataGridView1.Rows [e.RowIndex].Cells ["yfNum"].Value != null) { _modelOne.yfNum = decimal.Parse(dataGridView1.Rows [e.RowIndex].Cells ["yfNum"].Value.ToString( )); } else { _modelOne.yfNum = 0; } if (dataGridView1.Rows [e.RowIndex].Cells ["yfPrice"].Value != null) { _modelOne.yfPrice = decimal.Parse(dataGridView1.Rows [e.RowIndex].Cells ["yfPrice"].Value.ToString( )); } else { _modelOne.yfPrice = 0; } dataGridView1.Rows [e.RowIndex].Cells ["weight"].Value = _modelOne.yfNum * _modelOne.yfPrice; } }
//保存 public override void Save( ) { _model = new FishEntity.PresaleRequisitionHeadEntity( ); _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); if (GetPresaleRequisition( ) == false) { return; } _model.createman = FishEntity.Variable.User.username; _model.createtime = _bll.getDate( ); _model.modifyman = _model.createman; _model.modifytime = _model.createtime; List <FishEntity.PresaleRequisitionBodyEntity> modelList = new List <FishEntity.PresaleRequisitionBodyEntity> ( ); DataViewOne(modelList); _bll = new FishBll.Bll.PresaleRequisitionBll( ); if (state == "add") { result = _bll.Add(_model, modelList); } else if (state == "edit") { result = _bll.Edit(_model, modelList); } if (result == true) { MessageBox.Show("保存成功"); tmiSave.Visible = false; tmiCancel.Visible = false; tmiAdd.Visible = true; tmiModify.Visible = true; tmiQuery.Visible = true; tmiDelete.Visible = true; tmiClose.Visible = true; tmiReview.Visible = true; //panel2 . Enabled = false; } else { MessageBox.Show("保存失败,请重试"); } base.Save( ); }
public void setValue(FishEntity.PresaleRequisitionBodyEntity _model, bool state) { label.Text = string.Empty; txtSignplace.Text = texProcudts.Text = _model.yfUnit; if (_model.yfdb.ToString() != "" && _model.yfdb.ToString() != null) { label.Text += "蛋白≥" + _model.yfdb.ToString() + ","; } if (_model.yftvn.ToString() != "" && _model.yftvn.ToString() != null) { label.Text += "TVN≤" + _model.yftvn.ToString() + ","; } if (_model.yfza.ToString() != "" && _model.yfza.ToString() != null) { label.Text += "组胺≤" + _model.yfza.ToString() + ","; } if (_model.yfFFA.ToString() != "" && _model.yfFFA.ToString() != null) { label.Text += "FFA≤" + _model.yfFFA.ToString() + ","; } if (_model.yfzf.ToString() != "" && _model.yfzf.ToString() != null) { label.Text += "脂肪≤" + _model.yfzf.ToString() + ","; } if (_model.yfsf.ToString() != "" && _model.yfsf.ToString() != null) { label.Text += "水分≤" + _model.yfsf.ToString() + ","; } if (_model.yfshy.ToString() != "" && _model.yfshy.ToString() != null) { label.Text += "沙和盐≤" + _model.yfshy.ToString() + ","; } if (_model.yfs.ToString() != "" && _model.yfs.ToString() != null) { label.Text += "沙子≤" + _model.yfs.ToString() + ","; } label.Text += "国外SGS,不得发霉、有异味或掺杂其他杂物,"; label.Text += "且应符合国家质量标准。"; if (state == true) { texProduct.Text = _model.yfUnit; label1.Text = string.Empty; if (_model.yfcdb.ToString() != "" && _model.yfcdb.ToString() != null) { label1.Text += "粗蛋白≤" + _model.yfcdb.ToString() + ","; } if (_model.yftvntwo.ToString() != "" && _model.yftvntwo.ToString() != null) { label1.Text += "TVN≤" + _model.yftvntwo.ToString() + ","; } if (_model.yfhf.ToString() != "" && _model.yfhf.ToString() != null) { label1.Text += "灰份≤" + _model.yfhf.ToString() + ","; } label1.Text += "国内检测指标平均值。"; //texCDB . Text = _model . yfcdb . ToString ( ); //textTVN . Text = _model . yftvntwo . ToString ( ); //texHF . Text = _model . yfhf . ToString ( ); } else { label1.Text = string.Empty; } texCM.Text = _model.yfcm.ToString(); if (_model.yftdh == null) { texTDH.Text = string.Empty; } else { texTDH.Text = _model.yftdh.ToString(); } texZJH.Text = _model.yfzjh; texPP.Text = _model.yfpp; texCountry.Text = _model.yfCountry; }
public void DataViewOne(List <FishEntity.PresaleRequisitionBodyEntity> modelList) { dataGridView1.EndEdit( ); foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.IsNewRow) { continue; } _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); _modelOne.codeNum = _model.code; _modelOne.yfId = row.Cells ["yfId"].Value == null ? string.Empty : row.Cells ["yfId"].Value.ToString( ); _modelOne.yfName = row.Cells ["yfName"].Value == null ? string.Empty : row.Cells ["yfName"].Value.ToString( ); _modelOne.yfUnit = row.Cells ["yfUnit"].Value == null ? string.Empty : row.Cells ["yfUnit"].Value.ToString( ); _modelOne.yfVarieties = row.Cells ["yfVarieties"].Value == null ? string.Empty : row.Cells ["yfVarieties"].Value.ToString( ); _modelOne.yfNum = row.Cells ["yfNum"].Value == null ? 0 : Math.Round(decimal.Parse(row.Cells ["yfNum"].Value.ToString( )), 2); _modelOne.yfPrice = row.Cells ["yfPrice"].Value == null ? 0 : Math.Round(decimal.Parse(row.Cells ["yfPrice"].Value.ToString( )), 2); modelList.Add(_modelOne); } dataGridView2.EndEdit( ); foreach (DataGridViewRow row in dataGridView2.Rows) { if (row.IsNewRow) { continue; } _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); _modelOne.codeNum = _model.code; _modelOne.yfId = row.Cells ["yfId_one"].Value == null ? string.Empty : row.Cells ["yfId_one"].Value.ToString( ); _modelOne = modelList.Find((i) => { return(i.yfId.Equals(_modelOne.yfId)); }); if (_modelOne == null) { break; } _modelOne.yfdb = row.Cells ["yfdb"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfdb"].Value.ToString( ))); _modelOne.yftvn = row.Cells ["yftvn"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yftvn"].Value.ToString( ))); _modelOne.yfza = row.Cells ["yfza"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfza"].Value.ToString( ))); _modelOne.yfFFA = row.Cells ["yfFFA"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfFFA"].Value.ToString( ))); _modelOne.yfzf = row.Cells ["yfzf"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfzf"].Value.ToString( ))); _modelOne.yfsf = row.Cells ["yfsf"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfsf"].Value.ToString( ))); _modelOne.yfshy = row.Cells ["yfshy"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfshy"].Value.ToString( ))); _modelOne.yfs = row.Cells ["yfs"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfs"].Value.ToString( ))); } dataGridView3.EndEdit( ); foreach (DataGridViewRow row in dataGridView3.Rows) { _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); _modelOne.codeNum = _model.code; _modelOne.yfId = row.Cells ["yfId_tre"].Value == null ? string.Empty : row.Cells ["yfId_tre"].Value.ToString( ); _modelOne = modelList.Find((i) => { return(i.yfId.Equals(_modelOne.yfId)); }); if (_modelOne == null) { break; } _modelOne.yfcdb = row.Cells ["yfcdb"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfcdb"].Value.ToString( ))); _modelOne.yftvntwo = row.Cells ["yftvntwo"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yftvntwo"].Value.ToString( ))); _modelOne.yfhf = row.Cells ["yfhf"].Value == null ? 0 : Math.Round(Convert.ToDecimal(row.Cells ["yfhf"].Value.ToString( ))); } dataGridView4.EndEdit( ); foreach (DataGridViewRow row in dataGridView4.Rows) { _modelOne = new FishEntity.PresaleRequisitionBodyEntity( ); _modelOne.codeNum = _model.code; _modelOne.yfId = row.Cells ["yfId_for"].Value == null ? string.Empty : row.Cells ["yfId_for"].Value.ToString( ); _modelOne = modelList.Find((i) => { return(i.yfId.Equals(_modelOne.yfId)); }); if (_modelOne == null) { break; } _modelOne.yfcm = row.Cells ["yfcm"].Value == null ? string.Empty : row.Cells ["yfcm"].Value.ToString( ); _modelOne.yfzjh = row.Cells ["yfzjh"].Value == null ? string.Empty : row.Cells ["yfzjh"].Value.ToString( ); _modelOne.yftdh = row.Cells ["yftdh"].Value == null ? string.Empty : row.Cells ["yftdh"].Value.ToString( ); _modelOne.yfpp = row.Cells ["yfpp"].Value == null ? string.Empty : row.Cells ["yfpp"].Value.ToString( ); _modelOne.yfCountry = row.Cells ["yfCountry"].Value == null ? string.Empty : row.Cells ["yfCountry"].Value.ToString( ); } }