public ItemInfoDialog(DataRow row, StadiumConfigDialog parent) { staParent = parent; InitializeComponent(); if (row != null) { moduleID = new Guid(row["ID"].ToString()); config = Newtonsoft.Json.JsonConvert.DeserializeObject <JZStadiumConfig>(row["StadiumConfig"].ToString()); isActive = row["IsActive"].ToString() == "1" ? true : false; tb_moduleName.Text = row["Name"].ToString(); } }
private void ButtonOk_Click(object sender, EventArgs e) { #region config JZStadiumConfig config = new JZStadiumConfig(); config.DayList = new List <JZStadiumDay>(); config.Temperature = int.Parse(txtTemperature.Text); //同条件温度提醒值 config.StadiumRange = int.Parse(txtStadiumRange.Text); //龄期提醒范围 //fPH 批号 if (Sheet_Columns.Cells[0, 1].Value != null && Sheet_Columns.Cells[0, 1].Value.ToString().Trim() != "") { config.fPH = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[0, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[0, 1].Value.ToString().Trim() }; } else { config.fPH = null; } //fZJRQ 制件日期 if (Sheet_Columns.Cells[1, 1].Value != null && Sheet_Columns.Cells[1, 1].Value.ToString().Trim() != "") { config.fZJRQ = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[1, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[1, 1].Value.ToString().Trim() }; } else { config.fZJRQ = null; } //fSJBH 试件编号 if (Sheet_Columns.Cells[2, 1].Value != null && Sheet_Columns.Cells[2, 1].Value.ToString().Trim() != "") { config.fSJBH = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[2, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[2, 1].Value.ToString().Trim() }; } else { config.fSJBH = null; } //fSJSize 试件尺寸 if (Sheet_Columns.Cells[3, 1].Value != null && Sheet_Columns.Cells[3, 1].Value.ToString().Trim() != "") { config.fSJSize = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[3, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[3, 1].Value.ToString().Trim() }; } else { config.fSJSize = null; } //fBGBH 报告编号 if (Sheet_Columns.Cells[4, 1].Value != null && Sheet_Columns.Cells[4, 1].Value.ToString().Trim() != "") { config.fBGBH = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[4, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[4, 1].Value.ToString().Trim() }; } else { config.fBGBH = null; } //fWTBH 委托编号 if (Sheet_Columns.Cells[5, 1].Value != null && Sheet_Columns.Cells[5, 1].Value.ToString().Trim() != "") { config.fWTBH = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[5, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[5, 1].Value.ToString().Trim() }; } else { config.fWTBH = null; } //fAdded 附件信息 if (Sheet_Columns.Cells[6, 1].Value != null && Sheet_Columns.Cells[6, 1].Value.ToString().Trim() != "") { config.fAdded = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[6, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[6, 1].Value.ToString().Trim() }; } else { config.fAdded = null; } //ShuLiang 代表数量 if (Sheet_Columns.Cells[7, 1].Value != null && Sheet_Columns.Cells[7, 1].Value.ToString().Trim() != "") { config.ShuLiang = new QualifySetting() { SheetID = new Guid(Sheet_Columns.Cells[7, 1].Tag.ToString()), CellName = Sheet_Columns.Cells[7, 1].Value.ToString().Trim() }; } else { config.ShuLiang = null; } for (int i = 0; i < sheetView1.Rows.Count; i++) { JZStadiumDay sta = new JZStadiumDay(); int iDays = Int32.Parse(sheetView1.Cells[i, 0].Value.ToString()); if (iDays >= 0) {//大于0,表示天数,要转换成小时 iDays = iDays * 24; } else {//小于0表示小时数,直接转换成小时数 iDays = -1 * iDays; } sta.Days = iDays; if (sheetView1.Cells[i, 3].Value == null) { sta.IsParameterDays = false; } else { sta.IsParameterDays = Boolean.Parse(sheetView1.Cells[i, 3].Value.ToString()); } if (sheetView1.Cells[i, 4].Value != null && sheetView1.Cells[i, 4].Value.ToString().Trim() != "") { sta.PDays = new QualifySetting() { SheetID = new Guid(sheetView1.Cells[i, 4].Tag.ToString()), CellName = sheetView1.Cells[i, 4].Value.ToString().Trim() }; } else { sta.PDays = null; } if (sheetView1.Cells[i, 6].Value != null && sheetView1.Cells[i, 6].Value.ToString().Trim() != "") { sta.ValidInfo = new QualifySetting() { SheetID = new Guid(sheetView1.Cells[i, 6].Tag.ToString()), CellName = sheetView1.Cells[i, 6].Value.ToString().Trim() }; } else { sta.ValidInfo = null; } if (sheetView1.Cells[i, 1].Tag != null) { sta.ItemID = sheetView1.Cells[i, 1].Tag.ToString(); sta.ItemName = sheetView1.Cells[i, 1].Value.ToString(); } else { sta.ItemID = ""; sta.ItemName = ""; } config.DayList.Add(sta); } #endregion String json = Newtonsoft.Json.JsonConvert.SerializeObject(config); ModuleHelperClient.UpdateStadiumConfig(moduleID, json, cb_active.Checked); staParent.BindModelList(); this.Close(); }