/// <summary> /// 根据Id查询下发记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public AMS_SlipCustomerModel GetSlipReleaseListById(int id) { StringBuilder strWhere = new StringBuilder(); if (id > 0) { strWhere.AppendFormat(" Id='{0}'", id); } try { DataSet ds = slipRelease_dal.GetList(strWhere.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { AMS_SlipCustomerModel model = DataRowToAMS_SlipCustomerViewModel(ds.Tables[0].Rows[0]); return(model); } return(null); } catch { throw; } }
/// <summary> /// 保存 /// </summary> public bool AddSC() { try { if (string.IsNullOrEmpty(_Number) || _ImageUrl == null || _CustomerImage == null) { throw new Exception("信息填写不完整!"); } else { if (_IsPrint && (string.IsNullOrEmpty(_SlipTemplate.MainTitleName) || string.IsNullOrEmpty(_SlipTemplate.PreferentialInfo) || string.IsNullOrEmpty(_SlipTemplate.CustomerInfo))) { throw new Exception("信息填写不完整!"); } else { AMS_SlipCustomerModel samemodel = AMS_SlipCustomerBLL.GetSlipCustomerByNum(_Number); if (samemodel != null) { throw new Exception("已存在相同的编号!"); } AMS_SlipCustomerModel model = new AMS_SlipCustomerModel(); model.Number = _Number; model.EffectDate = _EffectDate.Date; model.EndDate = _EndDate.Date; model.IsPrint = _IsPrint; model.ImageUrl = _Number + "_" + _ImageUrl.UriSource.LocalPath.Substring(_ImageUrl.UriSource.LocalPath.LastIndexOf("\\") + 1); if (_IsPrint) { model.SlipTemplate = _SlipTemplate.ToXml(_Number); } model.CustomerImage = _Number + "_" + _CustomerImage.UriSource.LocalPath.Substring(_CustomerImage.UriSource.LocalPath.LastIndexOf("\\") + 1); FileOperate fo = new FileOperate(); if (!fo.UpdateFile(_CustomerImage.UriSource.LocalPath, model.CustomerImage, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("Logo上传失败!"); } if (!fo.UpdateFile(_ImageUrl.UriSource.LocalPath, model.ImageUrl, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("图片上传失败!"); } if (_IsPrint) { if (_SlipTemplate.LogoImage != null && !fo.UpdateFile(_SlipTemplate.LogoImage.UriSource.LocalPath, _Number + "_" + _SlipTemplate.LogoImage.UriSource.LocalPath.Substring(_SlipTemplate.LogoImage.UriSource.LocalPath.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("凭条Logo上传失败!"); } if (!fo.UpdateFile(_SlipTemplate.JuneberryLogo.UriSource.LocalPath, "南京智佰闻欣logo.png", SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("公司logo上传失败!"); } } if (AMS_SlipCustomerBLL.AddSlipCustomer(model) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("优惠劵保存失败!详情请查看日志文件!"); } return(true); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }