示例#1
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);
                    }
                }
            }
        }
示例#2
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();
                }
            }
        }