public bool DeleteAdvertisement(Model.AMS_Advertisement model)
 {
     try
     {
         return(dal_advertisement.Delete(model.ID));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool AddAdvertisement(Model.AMS_Advertisement model)
 {
     try
     {
         model.ReleaseDate = DateTime.Now;
         return(dal_advertisement.Add(model) > 0 ? true : false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private AMS.Model.AMS_Advertisement DataRowToAMS_Advertisement(DataRow dr)
 {
     //[ID],[Num],[Name],[EffectDate],[EndDate],[Type],[AdContent],[CustomerID],[OperatorName] ,[CompanyName],[UserName]
     AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
     model.AdContent    = dr["AdContent"].ToString();
     model.CustomerID   = int.Parse(dr["CustomerID"].ToString());
     model.EffectDate   = DateTime.Parse(dr["EffectDate"].ToString());
     model.EndDate      = DateTime.Parse(dr["EndDate"].ToString());
     model.ID           = int.Parse(dr["ID"].ToString());
     model.Name         = dr["Name"].ToString();
     model.Num          = dr["Num"].ToString();
     model.OperatorID   = int.Parse(dr["OperatorName"].ToString());
     model.OperatorName = dr["UserName"].ToString();
     model.ReleaseDate  = DateTime.Parse(dr["ReleaseDate"].ToString());
     model.Type         = (AMS.Model.Enum.AdType) int.Parse(dr["Type"].ToString());
     return(model);
 }
 public Model.AMS_Advertisement GetSingleAdvertisement(int ID)
 {
     try
     {
         Model.AMS_Advertisement model    = new Model.AMS_Advertisement();
         StringBuilder           strWhere = new StringBuilder();
         strWhere.Append(" ID='" + ID + "'");
         DataSet ds = dal_advertisementView.GetList(strWhere.ToString());
         if (ds.Tables[0].Rows.Count > 0)
         {
             return(DataRowToAMS_Advertisement(ds.Tables[0].Rows[0]));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 删除广告
 /// </summary>
 /// <returns></returns>
 public static bool DeleteAdvertisement(Model.AMS_Advertisement model)
 {
     AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
     try
     {
         return(bllService.DeleteAdvertisement(model));
     }
     catch (EndpointNotFoundException ex)
     {
         throw new AMS.Model.CustomerException("连接服务器失败");
     }
     catch (CommunicationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         ICommunicationObject ICommObjectService = bllService as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
Esempio n. 6
0
        public bool Save()
        {
            string functionName = "save";

            try
            {
                if (string.IsNullOrEmpty(PopAdvertModel.Num))
                {
                    ErrorMessage = "弹窗广告的编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(PopAdvertModel.Name))
                {
                    ErrorMessage = "弹窗广告的名称不能为空!";
                    return(false);
                }
                if (_PopImageInfo == null)
                {
                    ErrorMessage = "弹窗图片不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EffectDate == null)
                {
                    ErrorMessage = "弹窗广告的开始时间不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EndDate == null)
                {
                    ErrorMessage = "弹窗广告的结束时间不能为空!";
                    return(false);
                }
                if (PopAdvertModel.EndDate < PopAdvertModel.EffectDate)
                {
                    ErrorMessage = "弹窗广告的结束时间要大于开始时间!";
                    return(false);
                }
                if (PopAdvertModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PopAdvertModel.Num, PopAdvertModel.Name, Model.Enum.AdType.PopAd))
                {
                    ErrorMessage = "已存在存在相同名称或编号的弹窗广告!";
                    return(false);
                }
                PopAdvertModel.OperatorID = User.ID;
                PopAdvertModel.ImageFilePath.Clear();
                PopAdvertModel.ImageFilePath.Add(PopAdvertModel.PopImagePath);

                string resultstr = "";
                //TODO:保存&文件上传
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传媒体文件";
                Vm_ProgressBar.FullProgress = PopAdvertModel.ImageFilePath.Count;
                foreach (string upFileItem in PopAdvertModel.ImageFilePath)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + upFileItem + "\"……";
                    resultstr = fileUpload.UpdateFile(upFileItem, PopAdvertModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PopAd);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr);
                        Vm_ProgressBar.IsFinish();
                        return(false);
                    }
                }
                //更换文件名
                PopAdvertModel.PopImagePath = PopAdvertModel.Num + "_" + PopAdvertModel.PopImagePath.Substring(PopAdvertModel.PopImagePath.LastIndexOf("\\") + 1);
                for (int i = 0; i < PopAdvertModel.ImageFilePath.Count; i++)
                {
                    PopAdvertModel.ImageFilePath[i] = PopAdvertModel.Num + "_" + PopAdvertModel.ImageFilePath[i].Substring(PopAdvertModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                PopAdvertModel.Type = Model.Enum.AdType.PopAd;
                AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.Type       = Model.Enum.AdType.PopAd;
                model.ID         = PopAdvertModel.ID;
                model.Name       = PopAdvertModel.Name;
                model.Num        = PopAdvertModel.Num;
                model.OperatorID = PopAdvertModel.OperatorID;
                model.CustomerID = PopAdvertModel.CustomerID;
                model.AdContent  = PopAdvertModel.ToXml();
                model.EffectDate = PopAdvertModel.EffectDate;
                model.EndDate    = PopAdvertModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    //DOTO:添加
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存播放列表失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存
        /// </summary>
        public bool Save()
        {
            string functionName = "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 (PrintReceiptModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }

                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PrintReceiptModel.Num, PrintReceiptModel.Name, Model.Enum.AdType.PrintReceiptAd))
                {
                    ErrorMessage = "存在相同的编号或名称!";
                    return(false);
                }
                PrintReceiptModel.OperatorID = User.ID;
                //添加上传图片
                PrintReceiptModel.ImageFilePath.Clear();

                foreach (AMS.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 = "";
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传打印图片";
                Vm_ProgressBar.FullProgress = PrintReceiptModel.ImageFilePath.Count;
                for (int i = 0; i < PrintReceiptModel.ImageFilePath.Count; i++)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(PrintReceiptModel.ImageFilePath[i], PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PrintReceiptAd);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传图片失败!{0}", result);
                        return(false);
                    }
                    PrintReceiptModel.ImageFilePath[i] = PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                Getmodel();
                PrintReceiptModel.Type      = Model.Enum.AdType.PrintReceiptAd;
                PrintReceiptModel.AdContent = AMS.Model.PrintReceiptInfo.ToXml(PrintReceiptModel);
                Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.AdContent     = PrintReceiptModel.AdContent;
                model.CustomerID    = PrintReceiptModel.CustomerID;
                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.OperatorID    = PrintReceiptModel.OperatorID;
                model.Type          = Model.Enum.AdType.PrintReceiptAd;

                if (IsEdit)
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                return(true);
            }

            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        public bool Save()
        {
            string functionName = "Save";

            try
            {
                if (string.IsNullOrEmpty(CouponsModel.Num))
                {
                    ErrorMessage = "优惠券编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(CouponsModel.Name))
                {
                    ErrorMessage = "优惠券名称不能为空!";
                    return(false);
                }
                if (LogoImageInfo == null)
                {
                    ErrorMessage = "滚动LOGO图片不能为空!";
                    return(false);
                }
                if (CouponsItemList.Count < 1 && Station != 8)
                {
                    ErrorMessage = "弹窗图片不能为空!";
                    return(false);
                }
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.EffectDate == null)
                    {
                        ErrorMessage = "请选择开始日期!";
                        return(false);
                    }
                    if (item.EndDate == null)
                    {
                        ErrorMessage = "请选择结束日期!";
                        return(false);
                    }
                    if (item.EndDate < item.EffectDate)
                    {
                        ErrorMessage = "结束日期不能小于开始日期!";
                        return(false);
                    }
                }
                if (CouponsModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择优惠券客户!";
                    return(false);
                }
                if (CouponsModel.Station < 1)
                {
                    ErrorMessage = "请选择优惠券位置!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(CouponsModel.Num, CouponsModel.Name, Model.Enum.AdType.SlipCustomerAd))
                {
                    ErrorMessage = "存在相同的编号或名称!";
                    return(false);
                }
                CouponsModel.OperatorID = User.ID;
                //添加上传图片
                CouponsModel.ImageFilePath.Clear();
                CouponsModel.ImageFilePath.Add(_CouponsModel.LogoImage);
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.PopImageInfo != null)
                    {
                        bool isnew = true;
                        foreach (string samefile in CouponsModel.ImageFilePath)
                        {
                            if (samefile == item.PopImagePath)
                            {
                                isnew = false;
                                break;
                            }
                        }
                        if (isnew)
                        {
                            CouponsModel.ImageFilePath.Add(item.PopImagePath);
                        }
                    }
                    else
                    {
                        ErrorMessage = "优惠信息图片不能为空!";
                        return(false);
                    }
                    foreach (AMS.ViewModel.ViewModelPrintItem pitem in item.TemplateItem.PrintIiemList)
                    {
                        if (pitem.IsImage)
                        {
                            bool isnew = true;
                            foreach (string samefile in CouponsModel.ImageFilePath)
                            {
                                if (samefile == pitem.ImagePath)
                                {
                                    isnew = false;
                                    break;
                                }
                            }
                            if (isnew)
                            {
                                CouponsModel.ImageFilePath.Add(pitem.ImagePath);
                            }
                        }
                    }
                }
                //TODO:图片上传,优惠券保存
                string result = "";
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传优惠券图片";
                Vm_ProgressBar.FullProgress = CouponsModel.ImageFilePath.Count;
                for (int i = 0; i < CouponsModel.ImageFilePath.Count; i++)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1) + "\"……";
                    result = fileUpload.UpdateFile(CouponsModel.ImageFilePath[i], CouponsModel.Num + "_" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomerAd);
                    if (!string.IsNullOrEmpty(result))
                    {
                        ErrorMessage = string.Format("上传图片失败!{0}", result);
                        return(false);
                    }
                    CouponsModel.ImageFilePath[i] = CouponsModel.Num + "_" + CouponsModel.ImageFilePath[i].Substring(CouponsModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                //修改文件名
                CouponsModel.LogoImage = CouponsModel.Num + "_" + CouponsModel.LogoImage.Substring(CouponsModel.LogoImage.LastIndexOf("\\") + 1);
                foreach (ViewModelCouponsItem item in CouponsItemList)
                {
                    if (item.PopImageInfo != null)
                    {
                        item.PopImagePath = CouponsModel.Num + "_" + item.PopImagePath.Substring(item.PopImagePath.LastIndexOf("\\") + 1);
                        item.Getmodel();
                        if (item.CouponsItem.ID == "")
                        {
                            item.CouponsItem.ID = Guid.NewGuid().ToString() + item.CouponsItem.PpoImagePath;
                        }
                        if (CouponsModel.EffectDate < DateTime.Parse("2000-1-1") || CouponsModel.EffectDate > item.EffectDate)
                        {
                            CouponsModel.EffectDate = item.EffectDate;
                        }
                        if (CouponsModel.EndDate < DateTime.Parse("2000-1-1") || CouponsModel.EndDate < item.EndDate)
                        {
                            CouponsModel.EndDate = item.EndDate;
                        }
                        CouponsModel.PopItemList.Add(item.CouponsItem);
                    }
                }
                CouponsModel.Type      = Model.Enum.AdType.SlipCustomerAd;
                CouponsModel.AdContent = AMS.Model.CouponsInfo.ToXml(CouponsModel);
                Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.AdContent     = CouponsModel.AdContent;
                model.CustomerID    = CouponsModel.CustomerID;
                model.EffectDate    = CouponsModel.EffectDate;
                model.EndDate       = CouponsModel.EndDate;
                model.ID            = CouponsModel.ID;
                model.ImageFilePath = CouponsModel.ImageFilePath;
                model.Name          = CouponsModel.Name;
                model.Num           = CouponsModel.Num;
                model.OperatorID    = CouponsModel.OperatorID;
                model.Type          = Model.Enum.AdType.SlipCustomerAd;

                if (IsEdit)
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                return(true);
            }

            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }
Esempio n. 9
0
        public bool Save()
        {
            string functionName = "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 && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(PlaylistModel.Num, PlaylistModel.Name, Model.Enum.AdType.PlaylistAd))
                {
                    ErrorMessage = "已存在存在相同名称或编号的播放列表!";
                    return(false);
                }
                PlaylistModel.OperatorID = User.ID;
                PlaylistModel.ImageFilePath.Clear();
                PlaylistModel.MediaPlayList.Clear();
                foreach (ViewModel_VideoItem item in VideoItems)
                {
                    AMS.Model.PlaylistItemInfo newItem = new Model.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:保存&文件上传
                AMS.ServiceProxy.FileOperate fileUpload = new ServiceProxy.FileOperate();
                fileUpload.HandleProgress  += new ServiceProxy.EventHandleFileTransport(fileUpload_HandleProgress);
                Vm_ProgressBar.ProgressType = "上传媒体文件";
                Vm_ProgressBar.FullProgress = PlaylistModel.ImageFilePath.Count;
                foreach (string upFileItem in PlaylistModel.ImageFilePath)
                {
                    Vm_ProgressBar.ProgressName = "正在上传\"" + upFileItem + "\"……";
                    resultstr = fileUpload.UpdateFile(upFileItem, PlaylistModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PlaylistAd);
                    if (!string.IsNullOrEmpty(resultstr))
                    {
                        ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr);
                        Vm_ProgressBar.IsFinish();
                        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 = Model.Enum.AdType.PlaylistAd;
                AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.Type       = Model.Enum.AdType.PlaylistAd;
                model.ID         = PlaylistModel.ID;
                model.Name       = PlaylistModel.Name;
                model.Num        = PlaylistModel.Num;
                model.OperatorID = PlaylistModel.OperatorID;
                model.AdContent  = PlaylistModel.ToXml();
                model.EffectDate = PlaylistModel.EffectDate;
                model.EndDate    = PlaylistModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    //DOTO:添加
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存播放列表失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                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 (TitleAdvertModel.CustomerID < 0)
                {
                    ErrorMessage = "请选择客户!";
                    return(false);
                }
                if (!IsEdit && AMS.ServiceProxy.AdvertisementOperationService.ExistSameAdvert(TitleAdvertModel.Num, TitleAdvertModel.Name, Model.Enum.AdType.TitleAd))
                {
                    ErrorMessage = "已存在存在相同名称或编号的冠名广告!";
                    return(false);
                }
                TitleAdvertModel.OperatorID = User.ID;
                TitleAdvertModel.ImageFilePath.Clear();

                string resultstr = "";

                TitleAdvertModel.Type = Model.Enum.AdType.TitleAd;
                AMS.Model.AMS_Advertisement model = new Model.AMS_Advertisement();
                model.Type       = Model.Enum.AdType.TitleAd;
                model.ID         = TitleAdvertModel.ID;
                model.Name       = TitleAdvertModel.Name;
                model.Num        = TitleAdvertModel.Num;
                model.OperatorID = TitleAdvertModel.OperatorID;
                model.CustomerID = TitleAdvertModel.CustomerID;
                model.AdContent  = TitleAdvertModel.ToXml();
                model.EffectDate = TitleAdvertModel.EffectDate;
                model.EndDate    = TitleAdvertModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    return(AMS.ServiceProxy.AdvertisementOperationService.UpdateAdvertisement(model));
                }
                else
                {
                    //DOTO:添加
                    return(AMS.ServiceProxy.AdvertisementOperationService.AddAdvertisement(model));
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存失败!{0}", resultstr);
                    return(false);
                }
                return(true);
            }
            catch (AMS.Model.CustomerException ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, ex.ErrorSourcesClass, ex.ErrorSourcesFunction);
                return(false);
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("{0} 出自{1}.{2}", ex.Message, CLASSNAME, functionName);
                return(false);
            }
        }