Example #1
0
        public int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            ushort len = BitConverter.ToUInt16(Buffer, cursor);

            cursor += TypeSizes.SHORT;

            for (ushort i = 0; i < len; i++)
            {
                Characters.Add(new CharSelectItem(Buffer, cursor));
                cursor += Characters[i].ByteLength;
            }

            len     = BitConverter.ToUInt16(Buffer, cursor);
            cursor += TypeSizes.SHORT;

            MOTD    = Util.Encoding.GetString(Buffer, cursor, len);
            cursor += MOTD.Length;

            byte blen = Buffer[cursor];

            cursor++;

            for (byte i = 0; i < blen; i++)
            {
                Ads.Add(new CharSelectAd(Buffer, cursor));
                cursor += Ads[i].ByteLength;
            }

            return(cursor - StartIndex);
        }
 public void AddAdvertisement(AdvertisementInstance advertisement)
 {
     Ads.Add(advertisement);
     if (advertisement.Type != this)
     {
         advertisement.Type = this;
     }
 }
Example #3
0
 public void AddAdvertisement(AdvertisementInstance advertisement)
 {
     Ads.Add(advertisement);
     if (advertisement.Brand != this)
     {
         advertisement.Brand = this;
     }
 }
Example #4
0
        public IActionResult Addad(string name, string number, string text)
        {
            if (name == null)
            {
                name = "";
            }
            List <int> x = new List <int>();

            if (HttpContext.Session.Get <List <int> >("user") != null)
            {
                x = HttpContext.Session.Get <List <int> >("user");
            }
            Ads ad = new Ads(@"Data Source=.\sqlexpress;Initial Catalog=ADS;Integrated Security=True;");
            int y  = ad.Add(name, number, text);

            x.Add(y);
            HttpContext.Session.Set("user", x);
            return(Redirect("/home/home"));
        }
Example #5
0
        public int SaveNewAd(AdFullDTO ad, out string message)
        {
            message = "";
            if (ad.Title.Length > 200)
            {
                message = "Title is more then 200 characters";
                return(-1);
            }
            if (ad.Description.Length > 1000)
            {
                message = "Description is more then 1000 characters";
                return(-1);
            }
            if (ad.PhotoLinks.Count() > 3)
            {
                message = "More than 3 photo links is not allowed";
                return(-1);
            }

            Ad newAd = new Ad();

            newAd.Title       = ad.Title;
            newAd.Description = ad.Description;
            newAd.Price       = ad.Price;
            if (ad.PhotoLinks.Count() > 0)
            {
                var newPhotoLinks = new List <Photo>();
                foreach (var photoLink in ad.PhotoLinks)
                {
                    Photo newPhoto = new Photo();
                    newPhoto.PhotoURL = photoLink;
                    newPhotoLinks.Add(newPhoto);
                }
                newAd.Photos = newPhotoLinks;
            }
            Ads.Add(newAd);
            return(newAd.Id);
        }
Example #6
0
 void AddData()
 {
     try
     {
         Ads obj = new Ads();
         obj.Name     = txtTitle.Text;
         obj.Link     = txtLink.Text;
         obj.Location = ddlLocation.SelectedValue;
         obj.Type     = ddlType.SelectedValue;
         obj.Width    = Convert.ToInt32(txtWidth.Text);
         obj.Height   = Convert.ToInt32(txtHeight.Text);
         obj.Item     = Convert.ToInt32(txtSort.Text);
         obj.View     = 0;
         obj.Image    = txtImage.Text;
         obj.Status   = chkStatus.Checked;
         obj.Add(obj);
         ShowMessage("Dữ liệu đã được cập nhật");
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Example #7
0
 public virtual void AddAd(WalkerAd Ad)
 {
     Ads.Add(Ad);
 }
Example #8
0
 protected void btnok_Click(object sender, System.EventArgs e)
 {
     if (base.Action.Equals(ActionType.Add.ToString()) && !base.IsAuthorizedOp(ActionType.Add.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else if (base.Action.Equals(ActionType.Modify.ToString()) && !base.IsAuthorizedOp(ActionType.Modify.ToString()))
     {
         base.ShowMsg("Không có thẩm quyền");
     }
     else
     {
         AdsInfo adsInfo = new AdsInfo();
         if (base.IsEdit)
         {
             adsInfo = Ads.GetDataById(base.OpID);
         }
         adsInfo.PlaceID     = WebUtils.GetInt(this.ddlADPlace.SelectedValue);
         adsInfo.AdType      = 1;
         adsInfo.AdName      = WebUtils.GetString(this.TextBox1.Text);
         adsInfo.AdText      = this.TextBox4.Text;
         adsInfo.AdMediaPath = WebUtils.GetString(this.TextBox6.Text);
         adsInfo.AdLink      = WebUtils.GetString(this.TextBox2.Text);
         adsInfo.BeginDate   = WebUtils.GetDateTime(this.timestart.Text);
         adsInfo.EndDate     = WebUtils.GetDateTime(this.timeend.Text);
         adsInfo.IsAudit     = this.isaudit.Checked;
         adsInfo.Lang        = base.cultureLang;
         if (string.IsNullOrEmpty(adsInfo.AdName))
         {
             base.ShowMsg("请输入广告名称");
         }
         else if (adsInfo.EndDate < adsInfo.BeginDate)
         {
             base.ShowMsg("广告截止日期不能小于起始日期");
         }
         else
         {
             if (base.Action.Equals(ActionType.Add.ToString()))
             {
                 adsInfo.Sort          = Ads.MaxSort + 1;
                 adsInfo.AutoTimeStamp = System.DateTime.Now;
                 if (Ads.Add(adsInfo) > 0)
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "添加广告[" + adsInfo.AdName + "] thành công");
                     base.Response.Redirect(string.Concat(new object[]
                     {
                         "AdsList.aspx?CatalogID=",
                         base.CurrentCatalogID,
                         "&Module=",
                         base.CurrentModuleCode,
                         "&PlaceID=",
                         WebUtils.GetQueryInt("PlaceID"),
                         "&action=View"
                     }));
                 }
                 else
                 {
                     base.ShowMsg("添加广告失败");
                 }
             }
             if (base.Action.Equals(ActionType.Modify.ToString()))
             {
                 if (Ads.Update(adsInfo))
                 {
                     PageBase.log.AddEvent(base.LoginAccount.AccountName, "修改广告[" + adsInfo.AdName + "] thành công");
                     base.Response.Redirect(string.Concat(new object[]
                     {
                         "AdsList.aspx?CatalogID=",
                         base.CurrentCatalogID,
                         "&Module=",
                         base.CurrentModuleCode,
                         "&PlaceID=",
                         adsInfo.PlaceID,
                         "&action=View"
                     }));
                 }
                 else
                 {
                     base.ShowMsg("修改广告失败");
                 }
             }
         }
     }
 }