Beispiel #1
0
        public ActionResult Edit(string uid)
        {
            ApplicationUser u = Db1.GetApplicationUser(uid);

            ViewBag.UserRole = Db1.GetUserRoleById(uid);
            return(View(Db1.GetApplicationUser(uid)));
        }
Beispiel #2
0
        public void Exercise01()
        {
            Db1             db1 = new Db1();
            MySqlConnection con = db1.Connect();

            db1.Show();
            db1.Disconnect();
        }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "Id,Viewable,Name")] Locale locale)
 {
     if (ModelState.IsValid)
     {
         Db1.hidePostBasedOnLocale(locale.Id);
         db.Entry(locale).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("List"));
     }
     return(View(locale));
 }
        public ActionResult DetermineAreaCat(string uid)
        {
            List <Category>  cats    = Db1.ListAllCategories();
            List <Area>      areas   = Db1.ListAllArea();
            CatAreaViewModel catPost = new CatAreaViewModel();

            catPost.Areas      = areas;
            catPost.Categories = cats;
            return(View(catPost));
            //return View(Db1.areas.FirstOrDefault());
        }
 public ActionResult Edit([Bind(Include = "Id,Viewable,Name")] Area area)
 {
     if (ModelState.IsValid)
     {
         Db1.hideLocaleBasedOnArea(area.Id);
         db.Entry(area).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("List"));
     }
     return(View(Db1.ListViewableAreas()));
 }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "Id,Name,Viewable")] Subcategory subcategory, int id1)
        {
            if (ModelState.IsValid)
            {
                subcategory.Viewable = true;
                subcategory          = Db1.AddSubToCat(subcategory, id1);
                db.Subcategories.Add(subcategory);
                return(RedirectToAction("List", "Subcategories"));
            }

            return(RedirectToAction("List", "Subcategories"));
        }
        public ActionResult Create([Bind(Include = "Id,Name")] Area area)
        {
            if (ModelState.IsValid)
            {
                area.Viewable = true;
                db.Areas.Add(area);
                db.SaveChanges();
                return(RedirectToAction("List"));
            }

            return(View(Db1.ListViewableAreas()));
        }
Beispiel #8
0
 public ActionResult Edit(string uid, string checkboxData)
 {
     if (checkboxData is null)
     {
         return(RedirectToAction("ListUsers"));
     }
     if (checkboxData.Equals("on"))
     {
         Db1.UpgradeToAdmin(uid);
     }
     return(RedirectToAction("ListUsers"));
 }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "Id,Name")] Locale locale, int id1)
        {
            if (ModelState.IsValid)
            {
                locale.Area_obj = db.Areas.Find(id1); //get the area object and attach it to the new area
                locale.Viewable = true;               // set local viewable to true
                db.Locales.Add(locale);
                db.SaveChanges();
                return(RedirectToAction("List"));
            }

            return(View(Db1.ListLocaleInArea(id1)));
        }
        public ActionResult Create(string AreaId, string CatId)
        {
            if (AreaId == null || AreaId.Equals("") || CatId == null || CatId.Equals(""))
            {
                return(HttpNotFound());
            }

            var SpecificCatAreaViewModel = new SpecificCatAreaViewModel();

            SpecificCatAreaViewModel.Are = Db1.FindArea(Int32.Parse(AreaId));
            SpecificCatAreaViewModel.Cat = Db1.FindCat(Int32.Parse(CatId));
            return(View(SpecificCatAreaViewModel));
        }
Beispiel #11
0
 public ActionResult Modify([Bind(Include = "Id,Name,Viewable")] Subcategory subcategory, int id1, int id2)
 {
     if (ModelState.IsValid)
     {
         //subcategory.Viewable = !subcategory.Viewable;
         Db1.hidePostBasedOnSubCat(id2);
         db.Entry(subcategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("List"));
     }
     ViewBag.catId = id1;
     return(View(subcategory));
 }
        public ActionResult UserPost(int AreaId, int?CatId, int?SubCatId)
        {
            AreaViewModel areaPost = new AreaViewModel();

            if (CatId != null && SubCatId != null)
            {
                areaPost.Posts = Db1.AreaPostSubCat(AreaId, SubCatId);
            }
            else
            {
                areaPost.Posts = Db1.AreaPostCat(AreaId, CatId);
            }
            return(View(areaPost));
        }
        protected void viewallapro_Click(object sender, EventArgs e)
        {
            addproduct.CssClass  = "Initial";
            alterpro.CssClass    = "Initial";
            deletepro.CssClass   = "Initial";
            viewproduct.CssClass = "Initial";
            viewallapro.CssClass = "Clicked";
            view.ActiveViewIndex = 5;
            DataSet ds = Validatesearch.GetProductsDetails();

            Db1.Visible    = true;
            Db1.DataSource = ds;
            Db1.DataMember = ds.Tables[0].TableName;
            Db1.DataBind();
        }
        public ActionResult Create(string Body, string Title, string Locales, string Subcategories, string AreaId, string CatId)
        {
            if (Body == null || Body.Equals("") || Title == null || Title.Equals("") || Request["Are.Locales"] == null || Request["Are.Locales"].Equals("") || Request["Cat.Subcategories"] == null || Request["Cat.Subcategories"].Equals(""))
            {
                ModelState.AddModelError("Are", "All the above values must be filled in order to proceed.");
                var SpecificCatAreaViewModel = new SpecificCatAreaViewModel();
                SpecificCatAreaViewModel.Are = Db1.FindArea(Int32.Parse(AreaId));
                SpecificCatAreaViewModel.Cat = Db1.FindCat(Int32.Parse(CatId));
                //Db1.purge();
                return(View(SpecificCatAreaViewModel));
            }

            Db1.CreatePost(Title, Body, Request["Are.Locales"], AreaId, CatId, Request["Cat.Subcategories"], User.Identity.GetUserId());
            return(RedirectToAction("UserPostList"));
        }
Beispiel #15
0
        public ActionResult UserPost(int LocaleId, int?CatId, int?SubCatId)
        {
            LocalePostViewModel localePost = new LocalePostViewModel();

            if (CatId != null && SubCatId != null)
            {
                localePost.Posts = Db1.LocalePostCat(LocaleId, SubCatId);
            }
            else
            {
                localePost.Posts = Db1.LocalePostSubCat(LocaleId, CatId);
            }

            return(View(localePost));
        }
        public ActionResult Create([Bind(Include = "Subject,Content")] Message message, int PostId)
        {
            if (ModelState.IsValid)
            {
                Post p = Db1.GetPostById(PostId);
                message.ReceiverId = p.Owner.Id;
                message.SenderId   = db.Users.Find(User.Identity.GetUserId()).Id;
                message.PostId     = p.Id;
                db.Messages.Add(message);
                db.SaveChanges();
                return(RedirectToAction("Inbox"));
            }

            return(View(message));
        }
 public ActionResult Modify([Bind(Include = "Id,Name,Viewable")] Category category)
 {
     if (ModelState.IsValid)
     {
         //category.Viewable = !category.Viewable;
         //if the category has been hidden
         if (!category.Viewable)
         {
             Db1.HideSubcategorybasedOnCat(category.Id);
         }
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("List", "Categories"));
     }
     return(RedirectToAction("List", "Categories"));
 }
 public ActionResult DetermineAreaCat(string Areas, string Categories, string uid)
 {
     if ((Areas.Equals("") || Areas == null) || (Categories == null || Categories.Equals("")))
     {
         ModelState.AddModelError("Categories", "Both of the Areas and Categories can't be empty!");
         List <Category>  cats    = Db1.ListAllCategories();
         List <Area>      areas   = Db1.ListAllArea();
         CatAreaViewModel catPost = new CatAreaViewModel();
         catPost.Areas      = areas;
         catPost.Categories = cats;
         return(View(catPost));
     }
     else
     {
         return(RedirectToAction("Create", "Posts", new { AreaId = Areas, CatId = Categories }));
     }
 }
        // GET: Message/Details/5
        public ActionResult Details(int?MessageId)
        {
            if (MessageId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Message message = db.Messages.Find(MessageId);

            if (message == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PostTitle   = Db1.GetPostTitle(message.PostId);
            ViewBag.PostId      = message.PostId;
            ViewBag.PostStatus  = Db1.GetPostStatus(message.PostId);
            ViewBag.SenderEmail = db.Users.Find(message.SenderId).UserName;
            return(View(message));
        }
Beispiel #20
0
        public ActionResult UserPost(int CatId, int SubCatId, int?LocaleId, int?AreaId)
        {
            SubcatPostViewModel subcatpost = new SubcatPostViewModel();

            subcatpost.Sub = Db1.FindSubcat(SubCatId);
            if (LocaleId != null && AreaId != null)
            {
                subcatpost.Posts = Db1.SubcatPostWithLocale(SubCatId, LocaleId);
            }
            else if (AreaId != null)
            {
                subcatpost.Posts = Db1.SubcatPostWithArea(SubCatId, AreaId);
            }
            else
            {
                subcatpost.Posts = Db1.SubcatPost(SubCatId);
            }
            return(View(subcatpost));
        }
        public ActionResult Index(string AreaName, string LocaleName)
        {
            if (LocaleName != null)
            {
                ViewBag.Header = LocaleName;
            }
            else if (AreaName != null)
            {
                ViewBag.Header = AreaName;
            }
            else
            {
                ViewBag.Header = "Default";
            }
            var model = new HomePageViewModel();

            model.Area = Db1.ListAreas();
            model.Cat  = Db1.ListAllCategories();
            return(View(model));
        }
        public ActionResult Create(int PostId)
        {
            Post p = Db1.GetPostById(PostId);

            // post do not exist
            if (p is null)
            {
                return(new HttpNotFoundResult("Cannot locate the post."));
            }
            // the post is valid
            if (Db1.DetermineExpiredOrNotViewable(p))
            {
                ViewBag.PostTitle = p.Title;
                return(View());
            }
            else
            {
                return(new HttpNotFoundResult("The post was deleted or expired"));
            }
        }
        public ActionResult UserPost(int CatId, int?LocaleId, int?AreaId, int?page)
        {
            CatPostViewModel catpost = new CatPostViewModel();

            catpost.Cat = Db1.FindCat(CatId);
            if (LocaleId != null && AreaId != null)//area and locale
            {
                catpost.Posts = Db1.CatPostWithLocale(CatId, LocaleId);
            }
            else if (AreaId != null)//only area
            {
                catpost.Posts = Db1.CatPostWithArea(CatId, AreaId);
            }
            else  //only category
            {
                catpost.Posts = Db1.CatPost(CatId);
            }
            //why is there not a only subcat?


            return(View(catpost.Posts.ToList().ToPagedList(page ?? 1, 10)));
        }
 public ActionResult List(int?page)
 {
     return(View(Db1.ListAllCategories().ToPagedList(page ?? 1, 10)));
     //return View(db.Categories.ToList());
 }
Beispiel #25
0
        /// <summary>
        /// 按测段导出二等水准手簿
        /// </summary>
        /// <param name="excelApp">Excel对象</param>
        /// <param name="fileName">成果文件名</param>
        /// <param name="partInfo">测段对象</param>
        /// <param name="unitName">测量单位名称</param>
        private void part2Excel(Excel.Application excelApp, string fileName, PartInfo partInfo, string unitName)
        {
            string strExcelFile = Path.GetDirectoryName(Application.ExecutablePath) + @"\观测手簿模版.xlt";
            Excel.Workbook  excelWB = excelApp.Workbooks.Add(strExcelFile);
            Excel.Worksheet excelSheet = excelWB.Sheets[1];// 工作表

            excelSheet.Cells[2, 3].Value =unitName; // 单位名称

            // 获得测站数据范围和数据总结范围
            Excel.Range theRange, theRange1, theRange2;

            theRange1 = excelSheet.Range[excelSheet.Cells[7, 1], excelSheet.Cells[9, 10]]; // 测站数据范围
            theRange2 = excelSheet.Range[excelSheet.Cells[10, 1], excelSheet.Cells[14, 10]]; //线路汇总区域范围

            int n = partInfo.StationCount; // 测站数
            theRange2.Cut(excelSheet.Range[excelSheet.Cells[10 + (n - 1) * 3, 1], excelSheet.Cells[14 + (n - 1) * 3, 10]]); // 先剪切赋值线路汇总区域范围

            string fName0, bName0;// 开始已知点点名,结束已知点点名
            fName0= bName0="";
            string fName, bName;//前视点点名,后视点点名
            double bPtH, fPtH;//前视点高程,后视点高程
            bPtH = fPtH = 0.0;
            fName=bName="";
            double Rf1, Rf2, Rb1, Rb2;//中丝读数
            double deltRf, deltRb;//读数差
            double Df1, Df2, Db1, Db2;//前后视距
            double deltD;//视距差
            double deltH1, deltH2, deltH;//单次高差,平均高差
            
            double  SumdeltD=0.0;//累计视距差

            theRange1.Copy();
            // 开始赋值观测手簿
            for (int i = 0; i < n; i++)
            {
                Application.DoEvents();

                fName = partInfo.StationList[i].FPtName;
                bName =partInfo.StationList[i].BPtName;
                if (i == 0) bName0 = bName; // 开始点
                if (i == n-1) fName0 = fName; // 结束点’

                //中丝读数
                Rf1 = partInfo.StationList[i].Rf1;
                Rf2 = partInfo.StationList[i].Rf2;
                Rb1 = partInfo.StationList[i].Rb1;
                Rb2 = partInfo.StationList[i].Rb2;
                //读数差
                deltRf = Rf1 - Rf2;
                deltRb = Rb1 - Rb2;
                //高差及平均高差
                deltH1 = Rb1 - Rf1;
                deltH2 = Rb2 - Rf2;
                deltH = partInfo.StationList[i].DeltH;
                //前、后视点高程
                bPtH = partInfo.StationList[i].BPtH;
                fPtH = partInfo.StationList[i].FPtH;
                //视距
                Db1 = partInfo.StationList[i].Db1;
                Db2 = partInfo.StationList[i].Db2;
                Df1 = partInfo.StationList[i].Df1;
                Df2 = partInfo.StationList[i].Df2;
                deltD = partInfo.StationList[i].DeltD;
                SumdeltD = SumdeltD + deltD;

                theRange = excelSheet.Range[excelSheet.Cells[7 +i * 3, 1], excelSheet.Cells[9 + i * 3, 10]];
                theRange.PasteSpecial(Excel.XlPasteType.xlPasteFormats);

                excelSheet.Cells[7 + i * 3, 1].Value = i + 1; // 序号

                excelSheet.Cells[7 + i * 3, 2].Value = bName; // 后视点
                excelSheet.Cells[7 + i * 3 + 1, 2].Value = fName; // 前视点

                excelSheet.Cells[7 + i * 3, 3].Value = Db1.ToString("0.00000"); // 后视距1
                excelSheet.Cells[7 + i * 3 + 1, 3].Value = Df1.ToString("0.00000"); // 前视距1
                excelSheet.Cells[7 + i * 3 + 2, 3].Value = deltD.ToString("0.00000"); // 视距差

                excelSheet.Cells[7 + i * 3, 4].Value = Db2.ToString("0.00000"); // 后视距2
                excelSheet.Cells[7 + i * 3 + 1, 4].Value = Df2.ToString("0.00000"); // 前视距2
                excelSheet.Cells[7 + i * 3 + 2, 4].Value = SumdeltD.ToString("0.00000"); // 累计视距差

                excelSheet.Cells[7 + i * 3, 5].Value = Rb1.ToString("0.00000"); // 后视读数1
                excelSheet.Cells[7 + i * 3 + 1, 5].Value = Rf1.ToString("0.00000"); // 前视读数1
                excelSheet.Cells[7 + i * 3 + 2, 5].Value = deltH1.ToString("0.00000"); // 高差1

                excelSheet.Cells[7 + i * 3, 6].Value = Rb2.ToString("0.00000"); // 后视读数2
                excelSheet.Cells[7 + i * 3 + 1, 6].Value = Rf2.ToString("0.00000"); // 前视读数2
                excelSheet.Cells[7 + i * 3 + 2, 6].Value = deltH2.ToString("0.00000"); // 高差2

                excelSheet.Cells[7 + i * 3, 7].Value = (deltRb * 1000).ToString("0.00"); // 后视读数差
                excelSheet.Cells[7 + i * 3 + 1, 7].Value = (deltRf * 1000).ToString("0.00"); // 前视读数差
                excelSheet.Cells[7 + i * 3 + 2, 7].Value = ((deltH1 - deltH2) * 1000).ToString("0.00"); // 高差互差

                excelSheet.Cells[7 + i * 3 + 2, 8].Value = deltH.ToString("0.00000"); // 高差

                excelSheet.Cells[7 + i * 3, 9].Value = bPtH.ToString("0.00000"); // 后视点高程
                excelSheet.Cells[7 + i * 3 + 1, 9].Value = fPtH.ToString("0.00000"); // 前视点高程
            }//endfor

            excelSheet.Cells[10 + (n - 1) * 3, 3].Value = partInfo.StartPtName;//线路开始点名
            excelSheet.Cells[10 + (n - 1) * 3 + 1, 3].Value = partInfo.EndPtName; //线路结束点名
            excelSheet.Cells[10 + (n - 1) * 3 + 2, 3].Value = (partInfo.Df / 1000).ToString("0.00000"); // 累计前视距
            excelSheet.Cells[10 + (n - 1) * 3 + 3, 3].Value = (partInfo.Db / 1000).ToString("0.00000"); // 累计后视距

            excelSheet.Cells[10 + (n - 1) * 3 + 1, 6].Value = (partInfo.Db-partInfo.Df).ToString("0.00000"); // 累计视距差
            excelSheet.Cells[10 + (n - 1) * 3 + 2, 6].Value = partInfo.dz.ToString("0.00000"); // 累计高差
            excelSheet.Cells[10 + (n - 1) * 3 + 3, 6].Value = ((partInfo.Db + partInfo.Df )/ 1000).ToString("0.00000"); // 测段距离
            
            //合并单元格
            for (int i = 0; i <= n; i++)
            {
                theRange = excelSheet.Range[excelSheet.Cells[7 + i * 3, 1], excelSheet.Cells[9 + i * 3, 1]];
                theRange.Merge();
            }//endfor

             excelWB.SaveAs(fileName);//保存文件
             excelWB.Close();
        }
Beispiel #26
0
 public ActionResult List(int id1, int?page)
 {
     return(View(Db1.ListAllSubCategories(id1).ToPagedList(page ?? 1, 10)));
 }
        public ActionResult ExpiredPosts(int?page)
        {
            var userId = User.Identity.GetUserId();

            return(View(Db1.findOneExpiredPosts(userId).ToPagedList(page ?? 1, 10)));
        }
Beispiel #28
0
 public ActionResult ListUsers(int?page)
 {
     return(View(Db1.AllUserList().ToList().ToPagedList(page ?? 1, 10)));
 }
        // GET: Message
        public ActionResult Inbox(int?page)
        {
            List <Message> res = Db1.GetInBoxMessage(User.Identity.GetUserId());

            return(View(res.ToPagedList(page ?? 1, 10)));
        }
 public ActionResult List(int?page)
 {
     return(View(Db1.ListViewableAreas().ToList().ToPagedList(page ?? 1, 10)));
 }