Example #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DateTime StartDate = ckbDate.Checked == true?DateTime.Today:Utils.GetDateTime(DatePicker1.Value);
            DateTime EndDate   = ckbDate.Checked == true?DateTime.MaxValue: Utils.GetDateTime(DatePicker2.Value);
            string   Position  = ltr_advPostion.Text;
            string   Category  = ddlCategory.SelectedValue;
            string   Range     = hdfAdRange.Value;
            string   Relation  = StringValidate.IsIntegerArray(hdfResult.Value) == true ? hdfResult.Value : "-1";
            string   link      = Utils.InputText(txtLink.Value);
            string   unitname  = Utils.InputText(txtBuyUnit.Value);
            int      advid     = Utils.GetInt(Request.QueryString["AdvId"], -1);
            string   imgpath   = Utils.GetFormValue("sfuPhotoImg$hidFileName");

            if (string.IsNullOrEmpty(imgpath))
            {
                imgpath = hdfoldimgpath.Value;
            }
            if (Category.Length > 0 && Relation.Length > 0 && unitname.Length > 0)
            {
                if (Range.Length <= 0 && Relation.Length <= 0)
                {
                    MessageBox.ResponseScript(this.Page, "alert('请选择投放范围!')");
                    BindRangeType(null, "", false);
                    IsDateUpdate = advid != -1 ? false : true;
                    return;
                }
                IList <int> intrelas = null;
                if (Range != "全国")
                {
                    intrelas = new List <int>();
                    string[] rels = Relation.Split(',');
                    foreach (string item in rels)
                    {
                        intrelas.Add(Convert.ToInt32(item));
                    }
                }
                if (advid != -1)
                {
                    if (StartDate > EndDate)
                    {
                        IsInsert = false;
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                else
                {
                    if (!(StartDate <= EndDate && StartDate >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
                    {
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                EyouSoft.Model.AdvStructure.AdvInfo info = new EyouSoft.Model.AdvStructure.AdvInfo();
                info.EndDate      = Convert.ToDateTime(EndDate);
                info.StartDate    = Convert.ToDateTime(StartDate);
                info.IssueTime    = DateTime.Now;
                info.OperatorId   = this.MasterUserInfo.ID;  //操作员编号
                info.OperatorName = this.MasterUserInfo.UserName;
                info.ContactInfo  = link;
                info.AdvType      = EyouSoft.Model.AdvStructure.AdvType.城市;                                                                         //广告类型
                info.Category     = (EyouSoft.Model.AdvStructure.AdvCategory)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvCategory), Category); //广告类别
                info.Position     = (EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position);
                info.Range        = (EyouSoft.Model.AdvStructure.AdvRange)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvRange), Range);          //投放类型
                info.Title        = Utils.InputText(txtBuyUnit.Value);
                info.Relation     = intrelas;
                info.ImgPath      = imgpath;// 上传的Logo
                #region 单位图片|图文广告,添加logo,url
                EyouSoft.Model.CompanyStructure.CompanyDetailInfo companyInfo = EyouSoft.BLL.CompanyStructure.CompanyInfo.CreateInstance().GetModel(hdfUnitId.Value);
                EyouSoft.Model.CompanyStructure.CompanyType?      unitType    = null;
                if (companyInfo != null)
                {
                    unitType         = Utils.GetCompanyType(companyInfo.ID); //获取公司类型
                    info.RedirectURL = unitType.HasValue?Utils.GetCompanyDomain(companyInfo.ID, unitType.Value):string.Empty;
                    //info.ImgPath = companyInfo.AttachInfo.CompanyLogo.ImagePath;

                    info.Title       = unitname;
                    info.CompanyId   = companyInfo.ID;
                    info.CompanyName = unitname;
                    info.ContactMQ   = hdfUnitMQ.Value;
                    info.Remark      = unitname;
                    companyInfo      = null;
                }

                #endregion

                int row        = 0;
                int intPostion = (int)((EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position));
                if (advid != -1)
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas, advid))
                    {
                        info.AdvId = advid;
                        row        = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().UpdateAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能修改!", hdfLisUrl.Value);
                        return;
                    }
                }
                else
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas))
                    {
                        row = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().InsertAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能再次插入!", "AddUnitAd.aspx?position=" + intPostion);
                        return;
                    }
                }
                info = null;
                pnlforver.Visible = ckbDate.Checked == true ? false : true;
                if (row == 1)
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作成功!", hdfLisUrl.Value);
                }
                else
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作失败!", hdfLisUrl.Value);
                }
            }
            else
            {
                MessageBox.ResponseScript(this.Page, "alert('内容请填写完整!');");
                BindRangeType(null, "", false);
                IsDateUpdate = advid != -1 ? false :true;
            }
        }
Example #2
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DateTime EndDate   = ckDate.Checked == true?DateTime.MaxValue:Utils.GetDateTime(DatePicker2.Value);
            DateTime StartDate = ckDate.Checked == true?DateTime.Today:Utils.GetDateTime(DatePicker1.Value);
            string   Position  = ltr_advPostion.Text;
            string   Category  = ddlCategory.SelectedValue;
            string   Range     = hdfAdRange.Value;
            string   Relation  = StringValidate.IsIntegerArray(hdfResult.Value) == true ? hdfResult.Value : "-1";
            string   url       = txtUrl.Value.Trim();
            string   advTitle  = Utils.GetText(txtAdvTitle.Value, 100);
            string   advRemark = Utils.GetText(txtAdvBrief.Value, 255);

            if (url == "")
            {
                url = Utils.EmptyLinkCode;
            }
            else
            {
                if (url.IndexOf("http://") < 0)
                {
                    url = Utils.InputText("http://" + url);
                }
            }
            string link         = Utils.InputText(txtLink.Value);
            string imgpath      = Utils.GetFormValue("sfuPhotoImg$hidFileName");
            string imgpathThumb = Utils.GetFormValue("sfuSmallPhotoImg$hidFileName");
            string unitname     = Utils.InputText(txtBuyUnit.Value);
            string unitid       = Utils.InputText(hdfUnitId.Value);

            if (string.IsNullOrEmpty(imgpath))
            {
                imgpath = hdfoldimgpath.Value;
            }
            if (string.IsNullOrEmpty(imgpathThumb))
            {
                imgpathThumb = this.hdfoldimgpathSmall.Value;
            }

            int advid = Utils.GetInt(Request.QueryString["AdvId"], -1);           //修改 广告id

            if (Category.Length > 0 && imgpath.Length > 0 && unitid.Length > 0 && unitname.Length > 0)
            {
                if (Range.Length <= 0 && Relation.Length <= 0)
                {
                    MessageBox.ResponseScript(this.Page, "alert('请选择投放范围!');");
                    BindRangeType(null, "", false);
                    IsDateUpdate = advid != -1 ? false : true;
                    return;
                }
                IList <int> intrelas = null;
                if (Range != "全国")
                {
                    intrelas = new List <int>();
                    string[] rels = Relation.Split(',');
                    foreach (string item in rels)
                    {
                        intrelas.Add(Convert.ToInt32(item));
                    }
                }
                if (advid != -1)  //修改
                {
                    if (StartDate > EndDate)
                    {
                        IsInsert = false;
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                else
                {
                    if (!(StartDate <= EndDate && StartDate >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
                    {
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                if (string.IsNullOrEmpty(url))
                {
                    url = Utils.EmptyLinkCode;
                }

                EyouSoft.Model.AdvStructure.AdvInfo info = new EyouSoft.Model.AdvStructure.AdvInfo();
                info.AdvType      = EyouSoft.Model.AdvStructure.AdvType.城市;                                                                         //广告类型
                info.Category     = (EyouSoft.Model.AdvStructure.AdvCategory)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvCategory), Category); //广告类别
                info.Relation     = intrelas;
                info.CompanyId    = unitid;
                info.CompanyName  = unitname;
                info.ContactMQ    = hdfUnitMQ.Value;
                info.ContactInfo  = link;
                info.Title        = Utils.InputText(txtBuyUnit.Value);
                info.StartDate    = Convert.ToDateTime(StartDate);
                info.EndDate      = Convert.ToDateTime(EndDate);
                info.ImgPath      = imgpath;      //大图
                info.AdvThumb     = imgpathThumb; //缩略图
                info.Title        = advTitle;
                info.Remark       = advRemark;
                info.IssueTime    = DateTime.Now;
                info.OperatorId   = this.MasterUserInfo.ID;  //操作员编号
                info.OperatorName = this.MasterUserInfo.UserName;
                info.RedirectURL  = url;
                info.Position     = (EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position);
                info.Range        = (EyouSoft.Model.AdvStructure.AdvRange)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvRange), Range);
                int row         = 0;
                int intPosition = (int)((EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position));
                if (advid != -1)
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas, advid))
                    {
                        info.AdvId = advid;
                        row        = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().UpdateAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能修改!", hdfListUrl.Value);
                        return;
                    }
                }
                else
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas))
                    {
                        row = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().InsertAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能再次插入!", "AddPhotoAd.aspx?position=" + intPosition);
                        return;
                    }
                }
                info = null;
                pnlforver.Visible = ckDate.Checked == true ? false : true;
                if (row == 1)
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作成功!", hdfListUrl.Value);
                }
                else
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作失败!", hdfListUrl.Value);
                }
            }
            else
            {
                MessageBox.ResponseScript(this.Page, "alert('内容请填写完整!');");
                BindRangeType(null, "", false);
                IsDateUpdate = advid != -1 ? false : true;
            }
        }
Example #3
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DateTime StartDate = ckbDate.Checked == true?DateTime.Today: Utils.GetDateTime(DatePicker1.Value);
            DateTime EndDate   = ckbDate.Checked == true?DateTime.MaxValue: Utils.GetDateTime(DatePicker2.Value);
            string   Position  = ltr_advPostion.Text;
            string   Category  = ddlCategory.SelectedValue;
            string   Range     = hdfAdRange.Value;
            string   Relation  = StringValidate.IsIntegerArray(hdfResult.Value) == true ? hdfResult.Value :"-1";
            string   link      = txtContact.Value;
            string   title     = Utils.InputText(txtTitle.Value);
            string   content   = Utils.EditInputText(fckContent.Value);
            string   unitname  = Utils.InputText(txtBuyUnit.Value);
            string   unitid    = Utils.InputText(hdfUnitId.Value);

            int advid = Utils.GetInt(Request.QueryString["AdvId"], -1);

            if (Category.Length > 0 && Range.Length > 0 && Relation.Length > 0 && content.Length > 0 && title.Length > 0 && unitname.Length > 0 && unitid.Length > 0)
            {
                if (Range.Length <= 0 && Relation.Length <= 0)
                {
                    MessageBox.ResponseScript(this.Page, "alert('请选择投放范围');");
                    BindRangeType(null, "", false);
                    IsDateUpdate = advid != -1 ? false : true;
                    return;
                }
                IList <int> intrelas = null;
                if (Range != "全国")
                {
                    intrelas = new List <int>();
                    string[] rels = Relation.Split(',');
                    foreach (string item in rels)
                    {
                        intrelas.Add(Convert.ToInt32(item));
                    }
                }
                if (advid != -1)  //修改
                {
                    if (StartDate > EndDate)
                    {
                        IsInsert = false;
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                else
                {
                    if (!(StartDate <= EndDate && StartDate >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))))
                    {
                        MessageBox.ResponseScript(this.Page, "alert('有效期填写错误!');");
                        BindRangeType(intrelas, Range, true);
                        return;
                    }
                }
                EyouSoft.Model.AdvStructure.AdvInfo info = new EyouSoft.Model.AdvStructure.AdvInfo();
                info.EndDate      = EndDate;
                info.StartDate    = StartDate;
                info.IssueTime    = DateTime.Now;
                info.OperatorId   = this.MasterUserInfo.ID; //操作员编号
                info.OperatorName = this.MasterUserInfo.UserName;
                info.Title        = title;
                info.Remark       = content;
                info.CompanyId    = unitid;
                info.CompanyName  = unitname;
                info.ContactInfo  = link;
                info.ContactMQ    = hdfUnitMQ.Value;
                info.AdvType      = EyouSoft.Model.AdvStructure.AdvType.城市;                                                                         //广告类型1
                info.Category     = (EyouSoft.Model.AdvStructure.AdvCategory)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvCategory), Category); //广告类别
                info.Position     = (EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position);
                info.Range        = (EyouSoft.Model.AdvStructure.AdvRange)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvRange), Range);
                info.Relation     = intrelas;
                int intPosition = (int)((EyouSoft.Model.AdvStructure.AdvPosition)Enum.Parse(typeof(EyouSoft.Model.AdvStructure.AdvPosition), Position));
                int row         = 0;
                if (advid != -1)
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas, advid))
                    {
                        info.AdvId = advid;
                        row        = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().UpdateAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能修改!", hdfListUrl.Value);
                        return;
                    }
                }
                else
                {
                    if (info.Category == EyouSoft.Model.AdvStructure.AdvCategory.业114广告 || EyouSoft.BLL.AdvStructure.Adv.CreateInstance().IsValid(info.Position, info.StartDate, info.EndDate, info.Range, intrelas))
                    {
                        row = EyouSoft.BLL.AdvStructure.Adv.CreateInstance().InsertAdv(info);
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this.Page, "该位置的时间范围内已经存在广告,您不能再次插入!", "AddWritingAd.aspx?position=" + intPosition);
                        return;
                    }
                }
                info = null;
                pnlforver.Visible = ckbDate.Checked == true ? false : true;
                if (row == 1)
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作成功!", hdfListUrl.Value);
                }
                else
                {
                    MessageBox.ShowAndRedirect(this.Page, "操作失败!", hdfListUrl.Value);
                }
            }
            else
            {
                MessageBox.ResponseScript(this.Page, "alert('内容请填写完整!');");
                BindRangeType(null, "", false);
                IsDateUpdate = advid != -1 ? false : true;
            }
        }