private void BindMacineInfo() { DataSet dsMachineInfo = new GardenInfoSystem().GetMachineInfo(); if (dsMachineInfo != null) { if (dsMachineInfo.Tables[0].Rows.Count > 0) { gdMachineInfo.DataSource = dsMachineInfo.Tables[0]; txtTerminal.DataBindings.Add("EditValue",dsMachineInfo.Tables[0],"machine_address"); txtVol.DataBindings.Add("EditValue",dsMachineInfo.Tables[0],"machine_volumn"); } } }
private void smbDelete_Click(object sender, System.EventArgs e) { UnBindingMachineInfo(); int addr = Convert.ToInt32(gridView1.GetDataRow(gridView1.GetSelectedRows()[0])[0]); int rtnValue = new GardenInfoSystem().DeleteMachine(addr); if (rtnValue == 1) { MessageBox.Show("操作成功!"); } else { if (rtnValue == -1) { MessageBox.Show("至少应该保证有一台门口机处于工作状态,删除失败!"); } else { MessageBox.Show("操作失败!"); } } BindMacineInfo(); }
private void smbSave_Click(object sender, System.EventArgs e) { if (CheckMachineInfo(txtTerminal.Text)) { UnBindingMachineInfo(); int rtnValue = new GardenInfoSystem().AddNewMachine(Convert.ToInt32(txtTerminal.Text)); if (rtnValue == 1) MessageBox.Show("操作成功!"); else MessageBox.Show("操作失败!"); BindMacineInfo(); } }
//保存园所信息 private void simpleButton_GardenInfoSave_Click(object sender, System.EventArgs e) { if(!validateDataIsEmpty())//校验数据是否合法 { CPTT.SystemFramework.GardenInfo gardenInfoInstance = new CPTT.SystemFramework.GardenInfo(); if(gardenInfo.Tables[0].Rows.Count == 0)//数据库中没有园所数据做插入 { gardenInfoInstance.GardenID = Guid.NewGuid().ToString(); gardenInfoInstance.GardenName = textEdit_GardenName.Text.Trim(); gardenInfoInstance.GardenRegCode = textEdit_GardenRegCode.Text.Trim(); gardenInfoInstance.GardenAddr = textEdit_GardenAddress.Text.Trim(); gardenInfoInstance.GardenContact = textEdit_GardenContact.Text.Trim(); gardenInfoInstance.GardenFeature = textEdit_GardenFeature.Text.Trim(); gardenInfoInstance.GardenImage = writeInImage; try { int rowEffected = 0; GardenInfoSystem gardenInfoSystem = new GardenInfoSystem(); rowEffected = gardenInfoSystem.InsertGardenInfo(gardenInfoInstance); if(rowEffected > 0) { MessageBox.Show("园所信息插入成功!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } else { MessageBox.Show("园所信息插入失败,请重试!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } } catch(Exception ex) { CPTT.SystemFramework.Util.WriteLog(ex.Message,CPTT.SystemFramework.Util.EXCEPTION_LOG_TITLE); MessageBox.Show("园所信息插入失败,请重试!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } } else//数据库中存在园所信息做修改 { gardenInfoInstance.GardenID = gardenInfo.Tables[0].Rows[0]["info_gardenID"].ToString(); gardenInfoInstance.GardenName = textEdit_GardenName.Text.Trim(); gardenInfoInstance.GardenRegCode = textEdit_GardenRegCode.Text.Trim(); gardenInfoInstance.GardenAddr = textEdit_GardenAddress.Text.Trim(); gardenInfoInstance.GardenContact = textEdit_GardenContact.Text.Trim(); gardenInfoInstance.GardenFeature = textEdit_GardenFeature.Text.Trim(); gardenInfoInstance.GardenImage = writeInImage; try { int rowEffected = 0; GardenInfoSystem gardenInfoSystem = new GardenInfoSystem(); rowEffected = gardenInfoSystem.UpdateGardenInfo(gardenInfoInstance); if(rowEffected > 0) { MessageBox.Show("园所信息修改成功!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } else { MessageBox.Show("园所信息修改失败,请重试!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } } catch(Exception ex) { CPTT.SystemFramework.Util.WriteLog(ex.Message,CPTT.SystemFramework.Util.EXCEPTION_LOG_TITLE); MessageBox.Show("园所信息修改失败,请重试!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } } } else { MessageBox.Show("请检查数据填写是否规范!","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } }
//如果已存在园所信息则加载 private void LoadGardenInfo() { //权限 if ( Thread.CurrentPrincipal.Identity.Name.ToLower() == "admin" ) { simpleButton_ClassModi.Enabled = false; simpleButton_ClassModiReset.Enabled = false; simpleButton_ClassReSet.Enabled = false; simpleButton_ClassSave.Enabled = false; simpleButton_DeleteClass.Enabled = false; simpleButton_DeleteGrade.Enabled = false; simpleButton_GardenInfoReset.Enabled = false; simpleButton_GardenInfoSave.Enabled = false; simpleButton_GradeInfoReset.Enabled = false; simpleButton_GradeInfoSave.Enabled = false; simpleButton_GradeModify.Enabled = false; simpleButton_GradeModiReset.Enabled = false; } GardenInfoSystem gardenInfoSystem = new GardenInfoSystem(); try { //获取garden信息 gardenInfo = gardenInfoSystem.GetGardenInfo(); if(gardenInfo.Tables[0].Rows.Count > 0) { textEdit_GardenName.Text = gardenInfo.Tables[0].Rows[0]["info_gardenName"].ToString(); textEdit_GardenRegCode.Text = gardenInfo.Tables[0].Rows[0]["info_gardenRegCode"].ToString(); textEdit_GardenAddress.Text = gardenInfo.Tables[0].Rows[0]["info_gardenAddr"].ToString(); textEdit_GardenContact.Text = gardenInfo.Tables[0].Rows[0]["info_gardenContact"].ToString(); textEdit_GardenFeature.Text = gardenInfo.Tables[0].Rows[0]["info_gardenFeature"].ToString(); if(gardenInfo.Tables[0].Rows[0]["info_gardenGraphLocation"]!=System.DBNull.Value) { byte[] imageByte = (byte[])gardenInfo.Tables[0].Rows[0]["info_gardenGraphLocation"]; if(imageByte.Length>0) { pictureEdit_GardenImage.Image = Image.FromStream(new MemoryStream(imageByte)); } } simpleButton_GardenInfoSave.Text = "修改"; } radioGroup_Grade.SelectedIndex = 0; radioGroup_Class.SelectedIndex = 0; BindMacineInfo(); } catch(Exception ex) { CPTT.SystemFramework.Util.WriteLog(ex.Message,CPTT.SystemFramework.Util.EXCEPTION_LOG_TITLE); MessageBox.Show("加载园所信息错误,请重试.","系统提示!",MessageBoxButtons.OK,MessageBoxIcon.Information); } }
private void simpleButton1_Click(object sender, EventArgs e) { var tuple = new GrowUpReport().GetGradeAndClassCount(); label1.Visible = true; var year = comboBox1.SelectedItem.ToString().Replace("年", string.Empty); var date = checkedComboBoxEdit1.EditValue.ToString(); var selectedDate = date.Split(',').Select(d => new DateTime(Convert.ToInt32(year), Convert.ToInt32(d.Replace("月", string.Empty)), 1)).ToArray(); int reportCreate = 0; var gardenName = new GardenInfoSystem().GetGardenInfo().Tables[0].Rows[0]["info_gardenName"].ToString(); //班级数量*天数+班级数量+2*年级数量*天数+年级数量+3*天数 int totalReportCount = tuple.Item2 * (selectedDate.Length + 1) + tuple.Item1 * (2 * selectedDate.Length + 1) + 3 * selectedDate.Length; progressBar1.Maximum = totalReportCount; Action notify = () => { context.Send(d => label1.Text = string.Format("一大波报表正在生成,已经生成:{0}/{1}", ++reportCreate, totalReportCount), null); context.Send(d => progressBar1.Value = reportCreate, null); }; new Task(() => { new GrowUpReport().GenerateReportsPersonByPerson(gardenName, selectedDate, notify); //个人汇总 new GrowUpReport().GenerateReportsByClass(gardenName, selectedDate, notify); //班级统计汇总 new GrowUpReport().GenerateReportsByGrade(gardenName, selectedDate, notify); //年级统计汇总 new GrowUpReport().GenerateStatsReports(gardenName, selectedDate, notify); //年级汇总 new GrowUpReport().GenerateCheckReports(gardenName, selectedDate, notify); //幼儿体验,幼儿体验汇总 context.Post(d => { label1.Text = "全部生成完成"; simpleButton1.Enabled = true; progressBar1.Value = progressBar1.Maximum; ShowGrowUpReportPath(); }, null); }).Start(); simpleButton1.Enabled = false; }