/// <summary> /// 增加一条数据 /// </summary> public bool Add(SeatManage.ClassModel.AMS_Advertisement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AMS_Advertisement("); strSql.Append("[Num],[Name],[EffectDate],[EndDate],[Type],[AdContent])"); strSql.Append(" values ("); strSql.Append("@Num,@Name,@EffectDate,@EndDate,@Type,@AdContent)"); SqlParameter[] parameters = { new SqlParameter("@Num", SqlDbType.NVarChar, 50), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@EffectDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@Type", SqlDbType.Int), new SqlParameter("@AdContent", SqlDbType.Text) }; parameters[0].Value = model.Num; parameters[1].Value = model.Name; parameters[2].Value = model.EffectDate; parameters[3].Value = model.EndDate; parameters[4].Value = (int)model.Type; parameters[5].Value = model.AdContent; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private SeatManage.ClassModel.AMS_Advertisement DataRowToAMS_Advertisement(DataRow dr) { // [ID],[Num],[EffectDate],[EndDate],[Type],[AdContent] SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.ID = int.Parse(dr["ID"].ToString()); model.Name = dr["Name"].ToString(); model.Num = dr["Num"].ToString(); model.EffectDate = DateTime.Parse(dr["EffectDate"].ToString()); model.EndDate = DateTime.Parse(dr["EndDate"].ToString()); model.Type = (SeatManage.EnumType.AdType) int.Parse(dr["Type"].ToString()); model.AdContent = dr["AdContent"].ToString(); return(model); }
public string AddAdModel(SeatManage.ClassModel.AMS_Advertisement adInfo) { try { if (advertisement_dal.Add(adInfo)) { return(""); } else { return("添加失败"); } } catch { throw; } }
public string DeleteAdModel(SeatManage.ClassModel.AMS_Advertisement adInfo) { try { if (advertisement_dal.Delete(adInfo)) { return(""); } else { return("删除失败"); } } catch { throw; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SeatManage.ClassModel.AMS_Advertisement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AMS_Advertisement set "); strSql.Append("Num=@Num,"); strSql.Append("Name=@Name,"); strSql.Append("EffectDate=@EffectDate,"); strSql.Append("EndDate=@EndDate,"); strSql.Append("[Type]=@Type,"); strSql.Append("AdContent=@AdContent"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@Num", SqlDbType.NVarChar, 50), new SqlParameter("@Name", SqlDbType.NVarChar, 50), new SqlParameter("@EffectDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@Type", SqlDbType.Int), new SqlParameter("@AdContent", SqlDbType.Text), new SqlParameter("@ID", SqlDbType.Int) }; parameters[0].Value = model.Num; parameters[1].Value = model.Name; parameters[2].Value = model.EffectDate; parameters[3].Value = model.EndDate; parameters[4].Value = (int)model.Type; parameters[5].Value = model.AdContent; parameters[6].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(SeatManage.ClassModel.AMS_Advertisement model) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from AMS_Advertisement "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int) }; parameters[0].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 保存 /// </summary> /// <returns></returns> public bool Save() { try { if (string.IsNullOrEmpty(_NoteModel.Num)) { ErrorMessage = "编号不能为空!"; return(false); } if (string.IsNullOrEmpty(_NoteModel.Name)) { ErrorMessage = "名称不能为空!"; return(false); } if (_NoteImage == null) { ErrorMessage = "图片不能为空!"; return(false); } if (_NoteModel.EffectDate == null) { ErrorMessage = "开始时间不能为空!"; return(false); } if (_NoteModel.EndDate == null) { ErrorMessage = "结束时间不能为空!"; return(false); } if (_NoteModel.EndDate < _NoteModel.EffectDate) { ErrorMessage = "结束时间要大于开始时间!"; return(false); } if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(_NoteModel.Num, SeatManage.EnumType.AdType.SchoolNotice) != null) { ErrorMessage = "已存在存在相同名称或编号的通知!"; return(false); } string resultstr = ""; //TODO:保存&文件上传 SeatManage.Bll.FileOperate fileOperation = new SeatManage.Bll.FileOperate(); if (!fileOperation.UpdateFile(_NoteModel.NoteImagePath, _NoteModel.Num + "_" + _NoteModel.NoteImagePath.Substring(_NoteModel.NoteImagePath.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SchoolNotice)) { ErrorMessage = string.Format("文件{0}上传失败!", _NoteModel.NoteImagePath); return(false); } //更换文件名 _NoteModel.NoteImagePath = _NoteModel.Num + "_" + _NoteModel.NoteImagePath.Substring(_NoteModel.NoteImagePath.LastIndexOf("\\") + 1); _NoteModel.ImageFilePath.Clear(); _NoteModel.ImageFilePath.Add(_NoteModel.NoteImagePath); _NoteModel.Type = SeatManage.EnumType.AdType.SchoolNotice; SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.Type = SeatManage.EnumType.AdType.SchoolNotice; model.ID = _NoteModel.ID; model.Name = _NoteModel.Name; model.Num = _NoteModel.Num; model.AdContent = _NoteModel.ToXml(); model.EffectDate = _NoteModel.EffectDate; model.EndDate = _NoteModel.EndDate; if (IsEdit) { //TODO:更新 resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model); } else { //DOTO:添加 resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model); } if (!string.IsNullOrEmpty(resultstr)) { ErrorMessage = string.Format("保存失败!{0}", resultstr); return(false); } MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); return(true); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } }
public bool Save() { try { if (string.IsNullOrEmpty(PlaylistModel.Num)) { ErrorMessage = "播放列表的编号不能为空!"; return(false); } if (string.IsNullOrEmpty(PlaylistModel.Name)) { ErrorMessage = "播放列表的名称不能为空!"; return(false); } if (PlaylistModel.EffectDate == null) { ErrorMessage = "播放列表的开始时间不能为空!"; return(false); } if (PlaylistModel.EndDate == null) { ErrorMessage = "播放列表的结束时间不能为空!"; return(false); } if (PlaylistModel.EndDate < PlaylistModel.EffectDate) { ErrorMessage = "播放列表的结束时间要大于开始时间!"; return(false); } if (VideoItems.Count == 0) { ErrorMessage = "当前没有需要播放的文件!"; return(false); } if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(PlaylistModel.Num, SeatManage.EnumType.AdType.TitleAd) != null) { ErrorMessage = "已存在存在相同名称或编号的播放列表!"; return(false); } PlaylistModel.ImageFilePath.Clear(); PlaylistModel.MediaPlayList.Clear(); foreach (ViewModel_VideoItem item in VideoItems) { SeatManage.ClassModel.PlaylistItemInfo newItem = new SeatManage.ClassModel.PlaylistItemInfo(); newItem = item.VideoItemModel; newItem.MediaFileName = PlaylistModel.Num + "_" + newItem.MediaFileName.Substring(newItem.MediaFileName.LastIndexOf("\\") + 1); PlaylistModel.MediaPlayList.Add(newItem); bool isnew = true; foreach (string samefile in PlaylistModel.ImageFilePath) { if (samefile == item.VideoFliePath) { isnew = false; break; } } if (isnew) { PlaylistModel.ImageFilePath.Add(item.VideoFliePath); } } string resultstr = ""; //TODO:保存&文件上传 SeatManage.Bll.FileOperate fileUpload = new SeatManage.Bll.FileOperate(); foreach (string upFileItem in PlaylistModel.ImageFilePath) { if (!fileUpload.UpdateFile(upFileItem, PlaylistModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PlaylistAd)) { ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr); return(false); } } //更换文件名 for (int i = 0; i < PlaylistModel.ImageFilePath.Count; i++) { PlaylistModel.ImageFilePath[i] = PlaylistModel.Num + "_" + PlaylistModel.ImageFilePath[i].Substring(PlaylistModel.ImageFilePath[i].LastIndexOf("\\") + 1); } PlaylistModel.Type = SeatManage.EnumType.AdType.PlaylistAd; SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.Type = SeatManage.EnumType.AdType.PlaylistAd; model.ID = PlaylistModel.ID; model.Name = PlaylistModel.Name; model.Num = PlaylistModel.Num; model.AdContent = PlaylistModel.ToXml(); model.EffectDate = PlaylistModel.EffectDate; model.EndDate = PlaylistModel.EndDate; if (IsEdit) { //TODO:更新 resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model); } else { //DOTO:添加 resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model); } if (!string.IsNullOrEmpty(resultstr)) { ErrorMessage = string.Format("保存失败!{0}", resultstr); return(false); } MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); return(true); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } }
public static bool Get(int AdID) { try { AMS.Model.AMS_AdvertisementSchoolCopy adModel = AMS.ServiceProxy.AdvertisementOperationService.GetSchoolAdvert(AdID); if (adModel != null) { //上传下载类 AMS.ServiceProxy.FileOperate advertfileOperate = new AMS.ServiceProxy.FileOperate(); SeatManage.Bll.FileOperate seatmanagefileOperate = new SeatManage.Bll.FileOperate(); seatmanagefileOperate.Downloaded += new SeatManage.Bll.EventHandleFileTransport(seatmanagefileOperate_Downloaded); advertfileOperate.DownloadError += new AMS.ServiceProxy.EventHandleFileOperateError(fileOperate_DownloadError); //创建model SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.AdContent = adModel.AdContent; model.EffectDate = adModel.EffectDate; model.EndDate = adModel.EndDate; model.ImageFilePath = SeatManage.ClassModel.AMS_Advertisement.GetDownloadFile(adModel.AdContent); model.Name = adModel.Name; model.Num = adModel.Num; model.Type = (SeatManage.EnumType.AdType)System.Enum.Parse(typeof(SeatManage.EnumType.AdType), adModel.Type.ToString()); //图片下载 foreach (string file in model.ImageFilePath) { string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, file); //开始下载文件 if (!File.Exists(fileFullName)) { bool downloadResult = false; string error = advertfileOperate.FileDownLoad(fileFullName, file, (SeatManage.EnumType.SeatManageSubsystem)System.Enum.Parse(typeof(SeatManage.EnumType.SeatManageSubsystem), model.Type.ToString())); if (error == "") { downloadResult = true; } else { downloadResult = false; } if (!downloadResult) { //下载失败,直接返回false return(false); } } } //图片上传 foreach (string file in model.ImageFilePath) { string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, file); //文件下载完成,执行上传操作 bool uploadResult = seatmanagefileOperate.UpdateFile(fileFullName, file, (SeatManage.EnumType.SeatManageSubsystem)System.Enum.Parse(typeof(SeatManage.EnumType.SeatManageSubsystem), model.Type.ToString())); if (!uploadResult) { //上传失败,直接返回false,不再尝试其他操作 return(false); } } SeatManage.ClassModel.AMS_Advertisement sameModel = SeatManage.Bll.AdvertisementOperation.GetAdModel(model.Num, model.Type); string errorMessage = ""; if (sameModel == null) { errorMessage = SeatManage.Bll.AdvertisementOperation.AddAdModel(model); } else { model.ID = sameModel.ID; errorMessage = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model); } if (errorMessage != "") { SeatManage.SeatManageComm.WriteLog.Write(string.Format("更新广告遇到错误:{0}", errorMessage)); return(false); } } return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// 保存 /// </summary> public bool Save() { try { if (string.IsNullOrEmpty(PrintReceiptModel.Num)) { ErrorMessage = "编号不能为空!"; return(false); } if (string.IsNullOrEmpty(PrintReceiptModel.Name)) { ErrorMessage = "名称不能为空!"; return(false); } if (TemplateItem.PrintIiemList.Count < 1) { ErrorMessage = "打印项目不能为空!"; return(false); } if (PrintReceiptModel.EffectDate == null) { ErrorMessage = "请选择开始日期!"; return(false); } if (PrintReceiptModel.EndDate == null) { ErrorMessage = "请选择结束日期!"; return(false); } if (PrintReceiptModel.EndDate < PrintReceiptModel.EffectDate) { ErrorMessage = "结束日期不能小于开始日期!"; return(false); } if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(PrintReceiptModel.Num, SeatManage.EnumType.AdType.PrintReceiptAd) != null) { ErrorMessage = "存在相同的编号或名称!"; return(false); } //添加上传图片 PrintReceiptModel.ImageFilePath.Clear(); foreach (ViewModel.ViewModelPrintItem pitem in TemplateItem.PrintIiemList) { if (pitem.IsImage) { bool isnew = true; foreach (string samefile in PrintReceiptModel.ImageFilePath) { if (samefile == pitem.ImagePath) { isnew = false; break; } } if (isnew) { PrintReceiptModel.ImageFilePath.Add(pitem.ImagePath); } } } //TODO:图片上传,优惠券保存 string result = ""; SeatManage.Bll.FileOperate fileUpload = new SeatManage.Bll.FileOperate(); for (int i = 0; i < PrintReceiptModel.ImageFilePath.Count; i++) { if (!fileUpload.UpdateFile(PrintReceiptModel.ImageFilePath[i], PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PrintReceiptAd)) { ErrorMessage = string.Format("上传图片失败!{0}", result); return(false); } PrintReceiptModel.ImageFilePath[i] = PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1); } Getmodel(); PrintReceiptModel.Type = SeatManage.EnumType.AdType.PrintReceiptAd; PrintReceiptModel.AdContent = SeatManage.ClassModel.PrintReceiptInfo.ToXml(PrintReceiptModel); SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.AdContent = PrintReceiptModel.AdContent; model.EffectDate = PrintReceiptModel.EffectDate; model.EndDate = PrintReceiptModel.EndDate; model.ID = PrintReceiptModel.ID; model.ImageFilePath = PrintReceiptModel.ImageFilePath; model.Name = PrintReceiptModel.Name; model.Num = PrintReceiptModel.Num; model.Type = SeatManage.EnumType.AdType.PrintReceiptAd; string resultstr = ""; if (IsEdit) { //TODO:更新 resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model); } else { //DOTO:添加 resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model); } if (!string.IsNullOrEmpty(resultstr)) { ErrorMessage = string.Format("保存失败!{0}", resultstr); return(false); } MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); return(true); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } }
public bool Save() { string functionName = "save"; try { if (string.IsNullOrEmpty(TitleAdvertModel.Num)) { ErrorMessage = "编号不能为空!"; return(false); } if (string.IsNullOrEmpty(TitleAdvertModel.Name)) { ErrorMessage = "名称不能为空!"; return(false); } if (_TitleAdvertModel.TextContent == "") { ErrorMessage = "内容不能为空!"; return(false); } if (TitleAdvertModel.EffectDate == null) { ErrorMessage = "开始时间不能为空!"; return(false); } if (TitleAdvertModel.EndDate == null) { ErrorMessage = "结束时间不能为空!"; return(false); } if (TitleAdvertModel.EndDate < TitleAdvertModel.EffectDate) { ErrorMessage = "结束时间要大于开始时间!"; return(false); } if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(TitleAdvertModel.Num, SeatManage.EnumType.AdType.TitleAd) != null) { ErrorMessage = "已存在存在相同名称或编号的弹窗冠名!"; return(false); } TitleAdvertModel.ImageFilePath.Clear(); string resultstr = ""; TitleAdvertModel.Type = SeatManage.EnumType.AdType.TitleAd; SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement(); model.Type = SeatManage.EnumType.AdType.TitleAd; model.ID = TitleAdvertModel.ID; model.Name = TitleAdvertModel.Name; model.Num = TitleAdvertModel.Num; model.AdContent = TitleAdvertModel.ToXml(); model.EffectDate = TitleAdvertModel.EffectDate; model.EndDate = TitleAdvertModel.EndDate; if (IsEdit) { //TODO:更新 resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model); } else { //DOTO:添加 resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model); } if (!string.IsNullOrEmpty(resultstr)) { ErrorMessage = string.Format("保存失败!{0}", resultstr); return(false); } MessageBoxWindow mbw = new MessageBoxWindow(); mbw.viewModel.Message = "保存成功!"; mbw.viewModel.Type = Code.MessageBoxType.Success; mbw.ShowDialog(); return(true); } catch (Exception ex) { ErrorMessage = ex.Message; return(false); } }