public string cpcodeNum() { string str = string.Empty; if (_models == null) { _models = new FishEntity.BatchSheetsEntity(); } DateTime dt = _bll.getDate(); _models.codeNumContract = _bll.code(); if (_models.codeNumContract == string.Empty) { _models.codeNumContract = "CP" + dt.ToString("yyyyMMdd") + "001"; } else { if (_models.codeNumContract.Substring(2, 8) == dt.ToString("yyyyMMdd")) { _models.codeNumContract = "CP" + (Convert.ToInt64(_models.codeNumContract.Substring(2, 11)) + 1).ToString().PadLeft(8, '0'); } else { _models.codeNumContract = "CP" + dt.ToString("yyyyMMdd") + "001"; } } return(_models.codeNumContract); }
List <FishEntity.BatchSheetsEntity> getValue( ) { List <FishEntity.BatchSheetsEntity> _modelsList = new List <FishEntity.BatchSheetsEntity> ( ); dataGridView1.EndEdit( ); for (int i = 0; i < dataGridView1.Rows.Count; i++) { FishEntity.BatchSheetsEntity _eneity = new FishEntity.BatchSheetsEntity( ); _eneity.code = txtCode.Text; _eneity.fishId = dataGridView1.Rows [i].Cells ["fishId1"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["fishId1"].Value.ToString( ); if (!string.IsNullOrEmpty(_eneity.fishId)) { _eneity.codeNum = dataGridView1.Rows [i].Cells ["codeNum"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["codeNum"].Value.ToString( ); _eneity.codeNumContract = dataGridView1.Rows [i].Cells ["codeNumContract"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["codeNumContract"].Value.ToString( ); _eneity.qualitySpe = dataGridView1.Rows [i].Cells ["qualitySpe"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["qualitySpe"].Value.ToString( ); _eneity.country = dataGridView1.Rows [i].Cells ["country"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["country"].Value.ToString( ); _eneity.brand = dataGridView1.Rows [i].Cells ["brand"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["brand"].Value.ToString( ); _eneity.goods = dataGridView1.Rows [i].Cells ["goods"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["goods"].Value.ToString( ); _eneity.tons = dataGridView1.Rows [i].Cells ["tons"].Value == null ? 0 : Convert.ToDecimal(dataGridView1.Rows [i].Cells ["tons"].Value.ToString( )); _eneity.protein = dataGridView1.Rows [i].Cells ["protein"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["protein"].Value.ToString( ); _eneity.tvn = dataGridView1.Rows [i].Cells ["tvn"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["tvn"].Value.ToString( ); _eneity.salt = dataGridView1.Rows [i].Cells ["salt"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["salt"].Value.ToString( ); _eneity.acid = dataGridView1.Rows [i].Cells ["acid"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["acid"].Value.ToString( ); _eneity.ash = dataGridView1.Rows [i].Cells ["ash"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["ash"].Value.ToString( ); _eneity.histamine = dataGridView1.Rows [i].Cells ["histamine"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["histamine"].Value.ToString( ); _eneity.las = dataGridView1.Rows [i].Cells ["las"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["las"].Value.ToString( ); _eneity.das = dataGridView1.Rows [i].Cells ["das"].Value == null ? string.Empty : dataGridView1.Rows [i].Cells ["das"].Value.ToString( ); _eneity.price = dataGridView1.Rows [i].Cells ["price"].Value == null ? 0 : Convert.ToDecimal(dataGridView1.Rows [i].Cells ["price"].Value); _eneity.cost = dataGridView1.Rows [i].Cells ["cost"].Value == null ? 0 : Convert.ToDecimal(dataGridView1.Rows [i].Cells ["cost"].Value); _eneity.isSum = false; _modelsList.Add(_eneity); } } dataGridView2.EndEdit( ); FishEntity.BatchSheetsEntity _eneitys = new FishEntity.BatchSheetsEntity( ); _eneitys.code = txtCode.Text; _eneitys.fishId = dataGridView2.Rows [0].Cells ["sfishId"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sfishId"].Value.ToString( ); _eneitys.codeNum = dataGridView2.Rows [0].Cells ["scodeNum"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["scodeNum"].Value.ToString( ); _eneitys.codeNumContract = dataGridView2.Rows [0].Cells ["scodeNumContract"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["scodeNumContract"].Value.ToString( ); _eneitys.qualitySpe = dataGridView2.Rows [0].Cells ["squalitySpe"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["squalitySpe"].Value.ToString( ); _eneitys.country = dataGridView2.Rows [0].Cells ["scountry"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["scountry"].Value.ToString( ); _eneitys.brand = dataGridView2.Rows [0].Cells ["sbrand"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sbrand"].Value.ToString( ); _eneitys.goods = dataGridView2.Rows [0].Cells ["sgoods"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sgoods"].Value.ToString( ); _eneitys.tons = dataGridView2.Rows [0].Cells ["stons"].Value == null ? 0 : Convert.ToDecimal(dataGridView2.Rows [0].Cells ["stons"].Value.ToString( )); _eneitys.protein = dataGridView2.Rows [0].Cells ["sprotein"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sprotein"].Value.ToString( ); _eneitys.tvn = dataGridView2.Rows [0].Cells ["stvn"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["stvn"].Value.ToString( ); _eneitys.salt = dataGridView2.Rows [0].Cells ["ssalt"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["ssalt"].Value.ToString( ); _eneitys.acid = dataGridView2.Rows [0].Cells ["sacid"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sacid"].Value.ToString( ); _eneitys.ash = dataGridView2.Rows [0].Cells ["sash"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sash"].Value.ToString( ); _eneitys.histamine = dataGridView2.Rows [0].Cells ["shistamine"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["shistamine"].Value.ToString( ); _eneitys.las = dataGridView2.Rows [0].Cells ["slas"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["slas"].Value.ToString( ); _eneitys.das = dataGridView2.Rows [0].Cells ["sdas"].Value == null ? string.Empty : dataGridView2.Rows [0].Cells ["sdas"].Value.ToString( ); _eneitys.price = dataGridView2.Rows [0].Cells ["sprice"].Value == null ? 0 : string.IsNullOrEmpty(dataGridView2.Rows [0].Cells ["sprice"].Value.ToString( )) == true ? 0 : Convert.ToDecimal(dataGridView2.Rows [0].Cells ["sprice"].Value.ToString( )); _eneitys.cost = dataGridView2.Rows [0].Cells ["scost"].Value == null ? 0 : string.IsNullOrEmpty(dataGridView2.Rows [0].Cells ["scost"].Value.ToString( )) == true ? 0 : Convert.ToDecimal(dataGridView2.Rows [0].Cells ["scost"].Value.ToString( )); _eneitys.isSum = true; _modelsList.Add(_eneitys); return(_modelsList); }
public FormBatchSheet( ) { InitializeComponent( ); ReadColumnConfig(dataGridView1, "Set_101"); ReadColumnConfig(dataGridView2, "Set_102"); MenuCode = "M459"; ControlButtomRoles(); _bll = new FishBll.Bll.BatchSheetBll( ); _model = new FishEntity.BatchSheetEntity( ); _models = new FishEntity.BatchSheetsEntity( ); //readonlyCol ( ); }
//fishid public string fishid() { _models = new FishEntity.BatchSheetsEntity(); FishBll.Bll.BatchSheetBll bll = new FishBll.Bll.BatchSheetBll(); _models.fishId = bll.fishid(); string str = string.Empty; int sum = 0; if (_models.fishId == string.Empty) { str = "CP" + "10000001"; } else { sum = int.Parse(_models.fishId) + 1; str = "CP" + sum; } return(str); }
public FormBatchSheet(string code) { InitializeComponent(); ReadColumnConfig(dataGridView1, "Set_101"); ReadColumnConfig(dataGridView2, "Set_102"); MenuCode = "M459"; ControlButtomRoles(); _bll = new FishBll.Bll.BatchSheetBll(); _model = new FishEntity.BatchSheetEntity(); _models = new FishEntity.BatchSheetsEntity(); readonlyCol(); if (code != null && code != "") { _model = _bll.getModel(" code='" + code + "' "); code = string.Empty; if (_model != null) { txtCode.Text = _model.code; if (_model.productionDate < DateTime.MaxValue && _model.productionDate > DateTime.MinValue) { datePro.Value = Convert.ToDateTime(_model.productionDate); } if (string.IsNullOrEmpty(_model.code)) { return; } List <FishEntity.BatchSheetsEntity> modelList = _bll.modelList(_model.code); if (modelList == null || modelList.Count < 0) { return; } setValue(modelList); } else { _model = new FishEntity.BatchSheetEntity(); } } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } if (dataGridView1.Columns [e.ColumnIndex].Name.Equals("fishId1", StringComparison.OrdinalIgnoreCase)) { FormNewSelfcontrolWare form = new FormNewSelfcontrolWare( ); if (form.ShowDialog( ) == DialogResult.OK) { _models = form.getModel; int idx = dataGridView1.Rows.Add( ); dataGridView1.Rows [idx].Cells ["fishId1"].Value = _models.fishId; dataGridView1.Rows [idx].Cells ["codeNum"].Value = _models.codeNum; dataGridView1.Rows [idx].Cells ["codeNumContract"].Value = _models.codeNumContract; dataGridView1.Rows[idx].Cells["qualitySpe"].Value = _models.qualitySpe; dataGridView1.Rows [idx].Cells ["country"].Value = _models.country; dataGridView1.Rows[idx].Cells["price"].Value = _models.price; dataGridView1.Rows [idx].Cells ["brand"].Value = _models.brand; dataGridView1.Rows [idx].Cells ["protein"].Value = _models.protein; dataGridView1.Rows [idx].Cells ["tvn"].Value = _models.tvn; dataGridView1.Rows [idx].Cells ["salt"].Value = _models.salt; dataGridView1.Rows [idx].Cells ["acid"].Value = _models.acid; dataGridView1.Rows [idx].Cells ["ash"].Value = _models.ash; dataGridView1.Rows [idx].Cells ["histamine"].Value = _models.histamine; dataGridView1.Rows [idx].Cells ["las"].Value = _models.las; dataGridView1.Rows [idx].Cells ["das"].Value = _models.das; dataGridView1.Rows [idx].Cells ["tons"].Value = _models.tons; dataGridView1.Rows [idx].Cells ["rkCode"].Value = _models.rkCode; dataGridView1.Rows[idx].Cells["goods"].Value = "鱼粉"; setValueToSum( ); } } }
public string Numbering() { _models = new FishEntity.BatchSheetsEntity(); FishBll.Bll.BatchSheetBll bll = new FishBll.Bll.BatchSheetBll(); _models.codeNum = bll.Numbering(); string str = string.Empty; int sum = 0; if (_models.codeNum == string.Empty) { str = DateTime.Now.Year.ToString() + "P" + "0001001"; } else { sum = int.Parse(_models.codeNum) + 1000; _models.codeNum = sum.ToString(); while (_models.codeNum.Length != 7) { _models.codeNum = "0" + _models.codeNum; } str = DateTime.Now.Year.ToString() + "P" + _models.codeNum; } return(str); }