/// <summary> /// 更新幼儿园信息 /// </summary> /// <param name="gardenInfo">要更改的GardenInfo</param> /// <returns>返回影响的行数</returns> public int UpdateGardenInfo(GardenInfo gardenInfo) { int rowEffected = 0; try { DBCommandWrapper dbComWrapper = db.GetStoredProcCommandWrapper("UpdateGarden_Info"); dbComWrapper.AddInParameter("@info_gardenID",DbType.String,gardenInfo.GardenID); dbComWrapper.AddInParameter("@info_gardenName",DbType.String,gardenInfo.GardenName); dbComWrapper.AddInParameter("@info_gardenRegCode",DbType.String,gardenInfo.GardenRegCode); dbComWrapper.AddInParameter("@info_gardenAddr",DbType.String,gardenInfo.GardenAddr); dbComWrapper.AddInParameter("@info_gardenContact",DbType.String,gardenInfo.GardenContact); dbComWrapper.AddInParameter("@info_gardenFeature",DbType.String,gardenInfo.GardenFeature); dbComWrapper.AddInParameter("@info_gardenGraphLocation",DbType.Binary,gardenInfo.GardenImage); dbComWrapper.AddOutParameter("@rowEffected",DbType.Int32,4); db.ExecuteNonQuery(dbComWrapper); rowEffected = Convert.ToInt32(dbComWrapper.GetParameterValue("@rowEffected")); } catch(Exception ex) { throw ex; } return rowEffected; }
/// <summary> /// 调用DataAccess层更新幼儿园信息 /// </summary> /// <param name="gardenInfo">要更改的GardenInfo</param> /// <returns>返回影响的行数</returns> public int UpdateGardenInfo(GardenInfo gardenInfo) { int rowsAffected = 0; using(GardenInfoDataAccess gardenInfoDataAccess = new GardenInfoDataAccess()) { rowsAffected = gardenInfoDataAccess.UpdateGardenInfo(gardenInfo); } return rowsAffected; }
//保存园所信息 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); } }
/// <summary> /// 调用BusinessRule层更新幼儿园信息 /// </summary> /// <param name="gardenInfo">要更改的GardenInfo</param> /// <returns>返回影响的行数</returns> public int UpdateGardenInfo(GardenInfo gardenInfo) { return new GardenInfoRule().UpdateGardenInfo(gardenInfo); }
/// <summary> /// 调用BusinessRule层插入幼儿园信息 /// </summary> /// <param name="gardenInfo">要插入的GardenInfo</param> /// <returns>返回影响的行数</returns> public int InsertGardenInfo(GardenInfo gardenInfo) { return new GardenInfoRule().InsertGardenInfo(gardenInfo); }