public ActionResult Delete(long id) { try { // TODO: Add insert logic here InformationDao bdDao = new InformationDao(); bdDao.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Information/Edit/5 public ActionResult Edit(long id) { InformationDao dbDao = new InformationDao(); SetViewBag(); FeedbackInforDao feedDao = new FeedbackInforDao(); ViewBag.Feedback = feedDao.ToListFeebBackUser(id).ToArray <FeedbacInfokUser>(); ViewBag.Infomation = dbDao.FindByID(id); SetViewSupplier(ViewBag.Infomation.SupplierID); SetStatus(ViewBag.Infomation.Status); InforUserDao usDao = new InforUserDao(); List <InforUser> lstUP = usDao.FindByInforID(ViewBag.Infomation.InformationID); List <string> lstUPlogin = new List <string>(); foreach (var pUs in lstUP) { //string sLogin = pUs.LoginID.ToString(); lstUPlogin.Add(pUs.LoginID.ToString()); } SetUserBag(lstUPlogin.ToArray <string>()); if (ViewBag.Infomation.ContratorID != null) { ContratorDao contrDao = new ContratorDao(); Contrator objConTra = contrDao.FindByID(ViewBag.Infomation.ContratorID); string str = "<p><b>Tên chủ đầu tư: </b>" + objConTra.ContraName + "</p>"; str += "<p><b>Địa chỉ: </b>" + objConTra.Address + "</p>"; str += "<p><b>Thông tin liên hệ: </b>" + objConTra.FullName + "<b> Điện thoại: </b>" + objConTra.Phone + "</p>"; ViewBag.PrContraDetail = str; ViewBag.PrContraCode = objConTra.ContratorID; } if (ViewBag.Infomation.BuilderID != null) { BuilderDao buiDao = new BuilderDao(); Builder objBuilder = buiDao.FindByID(ViewBag.Infomation.BuilderID); ViewBag.PrBuiderCode = objBuilder.BuilderID; string str = ""; str = "<p><b>Tên nhà thầu: </b>" + objBuilder.BuilderName + "</p>"; str += "<p><b>Địa chỉ: </b>" + objBuilder.Address + "</p>"; str += "<p><b>Thông tin liên hệ: </b>" + objBuilder.FullName + "<b> Điện thoại: </b>" + objBuilder.Phone + "</p>"; ViewBag.BuiderDetail = str; } return(View()); }
public ActionResult Jobs() { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; InformationDao bdDao = new InformationDao(); db = new PTTDataContext(); //ViewBag.Info = from inf in db.Information // join uinfo in db.InforUsers on inf.InformationID equals uinfo.InforID // orderby inf.CreateDate ascending // where uinfo.LoginID== us.UserID // select new Information // { // Address = inf.Address, // BuilderID = inf.BuilderID, // ContratorID = inf.ContratorID, // CreateBy = inf.CreateBy, // CreateDate = inf.CreateDate, // DateLine = inf.DateLine, // Description = inf.Description, // InformationID = inf.InformationID, // ModifiedBy = inf.ModifiedBy, // ModifiedDate = inf.ModifiedDate, // Name = inf.Name, // Note = inf.Note, // Status = inf.Status, // SupplierID = inf.SupplierID // }; List <Information> listInfUser = new List <Information>(); var listInfo = db.Information.ToList(); var listUser = db.InforUsers.Where(u => u.LoginID == us.UserID).ToList(); foreach (var inf in listInfo) { foreach (var u in listUser) { if (u.InforID == inf.InformationID) { listInfUser.Add(inf); } } } ViewBag.Info = listInfUser; return(View()); }
// GET: FeedbackInfor public ActionResult Index(long id) { InformationDao bdDao = new InformationDao(); ViewBag.Project = bdDao.FindByID(id); FeedbackInforDao feedDao = new FeedbackInforDao(); ViewBag.Feedback = feedDao.ToListFeebBackUser(id).ToArray <FeedbacInfokUser>(); List <FeedbacInfokUser> fdnul = new List <FeedbacInfokUser>(); foreach (FeedbacInfokUser fb in ViewBag.Feedback) { if (fb.ChildID == null) { fdnul.Add(fb); } } ViewBag.FeedbackNull = fdnul.ToArray <FeedbacInfokUser>(); return(View()); }
public ActionResult Create(FormCollection data) { try { if (ModelState.IsValid) { SetViewBag(); // / string[] members = data.GetValues("drbMember"); //SetUserBag(members); string name = data["Name"].ToString(); string address = data["Address"].ToString(); string contratorID = data["txtContratorID"].ToString(); string builderID = data["txtBuilder"].ToString(); bool kt = true; //Kiem tra ma chu dau tu if (contratorID.Trim().Length > 0) { ContratorDao contraDAO = new ContratorDao(); Contrator objContra = contraDAO.FindByCode(contratorID.Trim()); if (objContra == null) { kt = false; ModelState.AddModelError("", "Mã chủ đầu tư không đúng!"); } } //Kiem tra nha thau thi cong if (contratorID.Trim().Length > 0) { BuilderDao buiderDao = new BuilderDao(); Builder objBuider = buiderDao.FindByCode(builderID.Trim()); if (objBuider == null) { kt = false; ModelState.AddModelError("", "Mã nhà thầu thi công không đúng!"); } } //string IsGroup = data["IsGroup"].ToString(); //string IsPublic = data["IsPublic"].ToString(); if (kt == true) { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; InformationDao bdDao = new InformationDao(); Information objProject = new Information(); // long iSupplierID = Convert.ToInt64(data["drlSupplier"].ToString()); // objProject.SupplierID = iSupplierID; objProject.CreateDate = Hepper.GetDateServer(); objProject.ModifiedDate = Hepper.GetDateServer(); objProject.CreateBy = us.UserName; objProject.ModifiedBy = us.UserName; objProject.Name = name; objProject.Description = data["txtDescription"].ToString(); objProject.Address = address; if (contratorID.Trim().Length > 0) { objProject.ContratorID = (new ContratorDao().FindByCode(contratorID.Trim()).ID); } if (builderID.Trim().Length > 0) { objProject.BuilderID = (new BuilderDao().FindByCode(builderID.Trim()).ID); } objProject.Status = 0; objProject.DateLine = Hepper.GetDateServer(); //Thêm dự án vào CSDL long projectID = bdDao.Insert(objProject); SetAlert("Thêm thành công", Common.CommonConstant.ALERT_SUCCESS); return(RedirectToAction("Index", "Home")); } else { SetAlert("Không thêm được", Common.CommonConstant.ALERT_WARNING); return(View()); } } else { SetAlert("Không thêm được", Common.CommonConstant.ALERT_WARNING); return(View()); } } catch { SetAlert("Không thêm được", "danger"); return(RedirectToAction("Create", "Information")); } }
public ActionResult Shared() { InformationDao bdDao = new InformationDao(); return(View(bdDao.ToListShared())); }
// GET: Information/Details/5 public ActionResult Manager() { InformationDao bdDao = new InformationDao(); return(View(bdDao.ToList())); }
public ActionResult Edit(FormCollection data) { try { InformationDao dbDao = new InformationDao(); long id = Convert.ToInt64(data["hdIDInfor"].ToString()); Information objProject = dbDao.FindByID(id); FeedbackInforDao feedDao = new FeedbackInforDao(); ViewBag.Feedback = feedDao.ToListFeebBackUser(id).ToArray <FeedbacInfokUser>(); // string cityID = data["CityID"].ToString(); // SetViewBag(cityID); // long categoryID = Convert.ToInt64(data["CategoryID"].ToString()); //long priceID = Convert.ToInt64(data["PriceID"].ToString()); if (ModelState.IsValid) { string name = data["Name"].ToString(); string address = data["Address"].ToString(); string contratorID = data["txtContratorID"].ToString(); string builderID = data["txtBuilder"].ToString(); string Note = data["txtNote"].ToString(); string[] members = data.GetValues("drbMember"); SetUserBag(members); bool kt = true; //Kiem tra ma chu dau tu if (contratorID.Trim().Length > 0) { ContratorDao contraDAO = new ContratorDao(); Contrator objContra = contraDAO.FindByCode(contratorID.Trim()); if (objContra == null) { kt = false; ModelState.AddModelError("", "Mã chủ đầu tư không đúng!"); } } //Kiem tra nha thau thi cong if (builderID.Trim().Length > 0) { BuilderDao buiderDao = new BuilderDao(); Builder objBuider = buiderDao.FindByCode(builderID.Trim()); if (objBuider == null) { kt = false; ModelState.AddModelError("", "Mã nhà thầu thi công không đúng!"); } } if (kt == true) { objProject.Address = address; if (contratorID.Trim().Length > 0) { objProject.ContratorID = (new ContratorDao().FindByCode(contratorID.Trim()).ID); } if (builderID.Trim().Length > 0) { objProject.BuilderID = (new BuilderDao().FindByCode(builderID.Trim()).ID); } // objProject.SupplierID = Convert.ToInt64(data["drlSupplier"]); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; if (data["drlStatus"] != null) { int iStatus = Convert.ToInt32(data["drlStatus"].ToString()); // long iSupplierID = Convert.ToInt64(data["drlSupplier"].ToString()); objProject.Status = iStatus; } objProject.ModifiedDate = Hepper.GetDateServer(); objProject.Description = data["txtDescription"].ToString(); objProject.ModifiedBy = us.UserName; objProject.Note = Note; objProject.Name = name; long infoID = dbDao.Update(objProject); //thêm danh sách nhóm vào trong dự án InforUserDao prUSDao = new InforUserDao(); if (members != null) { //Xóa nhóm thuộc dự án prUSDao.Delete(objProject.InformationID); // InforUser objPrUS = new InforUser(); //objPrUS.InforID = infoID; //objPrUS.LoginID = us.UserID; //objPrUS.IsAdmin = true; //prUSDao.Insert(objPrUS); foreach (string sUsID in members) { long usID = Convert.ToInt64(sUsID); if (usID != us.UserID) { InforUser objPrUSM = new InforUser(); objPrUSM.InforID = infoID; objPrUSM.LoginID = usID; objPrUSM.IsAdmin = false; prUSDao.Insert(objPrUSM); } } } SetAlert("Cập nhật thành công", Common.CommonConstant.ALERT_SUCCESS); return(RedirectToAction("Manager", "Information")); } else { SetAlert("Không cập nhật được", Common.CommonConstant.ALERT_WARNING); return(RedirectToAction("Manager", "Information")); } } else { SetAlert("Không cập nhật được", Common.CommonConstant.ALERT_WARNING); return(RedirectToAction("Manager", "Information")); } } catch { SetAlert("Không cập nhật được", Common.CommonConstant.ALERT_WARNING); return(RedirectToAction("Manager", "Information")); } }