Example #1
0
 protected void callbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
 {
     using (BalancesEntities db = new BalancesEntities())
     {
         int id          = Convert.ToInt32(e.Parameter);
         var publication = db.Publication.Single(em => em.Id == id);
         ASPxImage1.ImageUrl = publication.ImageUrl;
         litText.Text        = publication.Description;
     }
 }
Example #2
0
 protected void PublicationGridView_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
 {
     using (BalancesEntities db = new BalancesEntities())
     {
         var cat = Enumerable.FirstOrDefault(db.Category.Where(w => w.Name == e.Parameters));
         if (cat != null)
         {
             EntityDataSource1.WhereParameters["CategoryId"].DefaultValue = cat.Id.ToString();
             PublicationGridView.DataBind();
         }
     }
 }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ASPxNavBar1.ActiveGroup.Items.Clear();
         using (BalancesEntities db = new BalancesEntities())
         {
             foreach (var item in db.Category)
             {
                 ASPxNavBar1.ActiveGroup.Items.Add(new NavBarItem(item.Name, item.Name + item.Id));// (item.Name);
             }
         }
     }
 }
Example #4
0
        protected void NavCallbackPanel_Callback(object sender, CallbackEventArgsBase e)
        {
            if (e.Parameter == "new_item")
            {
                using (BalancesEntities db = new BalancesEntities())
                {
                    db.Category.Add(new Category()
                    {
                        Name = ASPxTextBox1.Text
                    });
                    db.SaveChanges();

                    ASPxNavBar1.ActiveGroup.Items.Clear();
                    foreach (var item in db.Category)
                    {
                        ASPxNavBar1.ActiveGroup.Items.Add(new NavBarItem(item.Name, item.Name + item.Id));// (item.Name);
                    }
                }
            }
        }
Example #5
0
        protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            e.CallbackData = String.Format("/Images/Publication/{0}", e.UploadedFile.FileName);
            string pathToFiles = Server.MapPath("/Images/Publication/");

            if (e.IsValid)
            {
                var Id = Convert.ToInt32(PublicationGridView.GetRowValues(PublicationGridView.EditingRowVisibleIndex, "Id"));
                e.UploadedFile.SaveAs(Path.Combine(pathToFiles, e.UploadedFile.FileName));

                using (BalancesEntities db = new BalancesEntities())
                {
                    var item = db.Publication.Find(Id);
                    if (item != null)
                    {
                        item.ImageUrl  = String.Format("/Images/Publication/{0}", e.UploadedFile.FileName);
                        e.CallbackData = item.ImageUrl;
                    }
                    db.SaveChanges();
                }
            }
        }