示例#1
0
 public List <Advertise> Advertise_Get(string Top, string Where, string Order)
 {
     try
     {
         List <Advertise> list = new List <Advertise>();
         list = AdvertiseBUS.Advertise_GetByTop(Top, Where, Order);
         return(list);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Data.Advertise obj = new Data.Advertise();
                obj.Name = txtName.Text;

                if (txtImage.Text.StartsWith("http://"))
                {
                    string    fileExt   = Path.GetExtension(txtImage.Text);
                    WebClient webClient = new WebClient();
                    if (fileExt.ToLower() == ".gif" || fileExt.ToLower() == ".png" || fileExt.ToLower() == ".jpg" || fileExt.ToLower() == ".jpeg")
                    {
                        string urlsave = "/Uploads/Advertise/" + Common.StringClass.RandomString(10) + fileExt;
                        webClient.DownloadFile(txtImage.Text, Request.PhysicalApplicationPath + urlsave);
                        obj.Image = urlsave;
                    }
                }
                else
                {
                    obj.Image = txtImage.Text;
                }
                obj.ImageSmall    = txtImagesmall.Text;
                obj.Summary       = txtsummary.Text;
                obj.Width         = "0";
                obj.Height        = "0";
                obj.Link          = txtLink.Text;
                obj.Target        = ddlTarget.SelectedValue;
                obj.ContentDetail = "";
                obj.Position      = ddlPosition.SelectedValue;
                obj.PageId        = ddlModule.SelectedValue;
                obj.Click         = "";
                obj.Ord           = txtOrd.Text != "" ? txtOrd.Text : "1";
                obj.Active        = chkActive.Checked ? "1" : "0";
                obj.Lang          = Lang;
                if (txtId.Text.Length == 0)
                {
                    obj.Id = Id;
                    AdvertiseBUS.Advertise_Insert(obj);
                }
                else
                {
                    obj.Id = txtId.Text;
                    AdvertiseBUS.Advertise_Update(obj);
                }
                BindGrid();
                pnView.Visible   = true;
                pnUpdate.Visible = false;
            }
        }
示例#3
0
 private void BindGrid()
 {
     if (ddlFilterPosition.SelectedValue == "" || ddlFilterPosition.SelectedValue == null)
     {
         grdAdvertise.DataSource = AdvertiseBUS.Advertise_GetByAll(Lang);
     }
     else
     {
         grdAdvertise.DataSource = AdvertiseBUS.Advertise_GetByTop("", "Lang='" + Lang + "' and Position=" + ddlFilterPosition.SelectedValue, "Id desc");
     }
     grdAdvertise.DataBind();
     if (grdAdvertise.PageCount <= 1)
     {
         grdAdvertise.PagerStyle.Visible = false;
     }
 }
示例#4
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            DataGridItem item = default(DataGridItem);

            for (int i = 0; i < grdAdvertise.Items.Count; i++)
            {
                item = grdAdvertise.Items[i];
                if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
                {
                    if (((CheckBox)item.FindControl("ChkSelect")).Checked)
                    {
                        string strId = item.Cells[1].Text;
                        AdvertiseBUS.Advertise_Delete(strId);
                    }
                }
            }
            grdAdvertise.CurrentPageIndex = 0;
            BindGrid();
        }
示例#5
0
        protected void grdAdvertise_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string strCA = e.CommandArgument.ToString();

            switch (e.CommandName)
            {
            case "Edit":
                Id = strCA;
                List <Data.Advertise> listE = AdvertiseBUS.Advertise_GetById(Id);
                txtId.Text      = strCA;
                txtName.Text    = listE[0].Name;
                txtsummary.Text = listE[0].Summary;
                if (listE[0].Image.Length > 0)
                {
                    txtImage.Text     = listE[0].Image;
                    imgImage.Visible  = true;
                    imgImage.ImageUrl = listE[0].Image;
                }
                if (listE[0].ImageSmall.Length > 0)
                {
                    txtImagesmall.Text = listE[0].Image;
                    Image1.Visible     = true;
                    Image1.ImageUrl    = listE[0].ImageSmall;
                }
                //else
                //{
                //    trImages.Visible = false;
                //}

                //txtWidth.Text = listE[0].Width;
                //txtHeight.Text = listE[0].Height;
                txtLink.Text              = listE[0].Link;
                ddlTarget.SelectedValue   = listE[0].Target;
                ddlPosition.SelectedValue = listE[0].Position;
                ddlModule.SelectedValue   = listE[0].PageId;
                txtOrd.Text       = listE[0].Ord;
                chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "True";

                pnView.Visible   = false;
                pnUpdate.Visible = true;
                break;

            case "Active":
                string strA = "";
                string str  = e.Item.Cells[2].Text;
                strA = str == "1" ? "0" : "1";
                SqlDataProvider sql = new SqlDataProvider();
                sql.ExecuteNonQuery("Update [Advertise] set Active=" + strA + "  Where Id='" + strCA + "'");
                BindGrid();
                break;

            case "Delete":
                AdvertiseBUS.Advertise_Delete(strCA);
                BindGrid();
                break;

            case "Image":
                Response.Redirect("/Admins/ImagesDetail.aspx?ImagesId=" + strCA + "");

                break;
            }
        }