public ActionResult Edit(User collection) { try { //TODO: Add update logic here if (ModelState.IsValid) { // TODO: Add insert logic here UserDao bdDao = new UserDao(); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.Password = Hepper.MD5Hash(collection.UserName + collection.Password); if (bdDao.Update(collection) > 0) { SetAlert("Sửa thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không sửa được", "danger"); } } return(View()); } catch { SetAlert("Không sửa được", "danger"); return(View()); } }
public ActionResult Publicer(FormCollection data) { try { NewsDao bdDao = new NewsDao(); News bd = bdDao.FindByID(Convert.ToInt64(data["NewsID"].ToString())); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; bd.ModifiedBy = us.UserName; bd.ModifiedDate = Hepper.GetDateServer(); bd.PublishedDate = Hepper.GetDateServer(); int Status = Convert.ToInt32(data["Status"]); bd.Status = Status; bd.ContentHtml = data["ContentHtml"].ToString(); if (bdDao.Update(bd) > 0) { SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); } } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View()); }
public ActionResult Edit(MenuType collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuTypeDao bdDao = new MenuTypeDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; // collection.CreatedBy = us.UserName; // collection.CreatedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); if (bdDao.Update(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Create(Category collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here CategoryDao bdDao = new CategoryDao(); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedDate = Hepper.GetDateServer(); collection.CreateBy = us.UserName; collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection) > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Edit(Product collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { // TODO: Add insert logic here ProductDao bdDao = new ProductDao(); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.ModifiedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; if (bdDao.Update(collection) > 0) { SetAlert("Sửa thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không sửa được", "danger"); } } return(View()); } catch { SetAlert("Không sửa được", "danger"); return(View()); } }
public ActionResult Create(Supplier collection) { try { SetViewBag(collection.CityID); SetViewBagDistrict(collection.DistrictID, collection.CityID); if (ModelState.IsValid) { // TODO: Add insert logic here SupplierDao bdDao = new SupplierDao(); UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.SupplierID = bdDao.GenaraCode("CU", 4); collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedDate = Hepper.GetDateServer(); collection.CreateBy = us.UserName; collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection) > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Edit(MathStudent collection) { MathStudentDao bdDao = new MathStudentDao(); GroupMathDropDownList(collection.GroupMathsID); try { UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); // ConvertExcelToXml convertXML = new ConvertExcelToXml(); //string xml = convertXML.GetXML(collection.Sources); // int i = 0; if (bdDao.Update(collection)) { SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); return(View()); } }
public ActionResult Create(About collection) { try { AboutDao bdDao = new AboutDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreateBy = us.UserName; collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); collection.LanguageID = "vi"; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); return(View()); } }
// GET: Login public ActionResult Index() { if (ControllerContext.HttpContext.Request.Cookies["login"] != null) { HttpCookie aCookie = Request.Cookies["login"]; var dao = new Model.DAO.UserDao(); var result = dao.Login(aCookie.Values["UserName"], Hepper.MD5Hash(aCookie.Values["UserName"] + aCookie.Values["Password"])); if (result == 1) { var us = dao.GetUserByUserName(aCookie.Values["UserName"]); UserLogin uslog = new UserLogin(); uslog.UserID = us.LoginID; uslog.UserName = us.UserName; uslog.FullName = us.FullName; uslog.Image = us.Image; uslog.LastLogIn = us.LastLogIn; Session[CommonConstant.USER_SESSION] = uslog; dao.LastLogin(us.LoginID, Hepper.GetDateServer()); return(RedirectToAction("Index", "Home")); } } else { return(View()); } return(View()); }
public ActionResult Edit(About collection) { AboutDao bdDao = new AboutDao(); try { UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); if (bdDao.Update(collection)) { SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); return(View()); } }
public ActionResult Supplier() { PTTDataContext db = new PTTDataContext(); SetCatagoryBag(); SetSupplierBag(); SetStatusBag(); ViewBag.Project = null; ViewBag.sdate = Hepper.GetDateServer().ToString("MM/dd/yyyy"); ViewBag.edate = Hepper.GetDateServer().ToString("MM/dd/yyyy"); return(View()); }
public ActionResult Edit(Contrator collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { // TODO: Add insert logic here ContratorDao bdDao = new ContratorDao(); bool kt = true; string taxid = collection.TaxID; Contrator objContrac = bdDao.FindByTaxID(taxid); if (objContrac != null) { if (objContrac.ID != collection.ID) { ModelState.AddModelError("", "Mã số thuế đã tồn tại!"); kt = false; } } if (kt == true) { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.ModifiedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; if (bdDao.Update(collection) > 0) { SetAlert("Sửa thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không sửa được", "danger"); } } } return(View()); } catch { SetAlert("Không sửa được", "danger"); return(View()); } }
public ActionResult Index(Models.LoginModel mode) { if (ModelState.IsValid) { var dao = new DBModel.DAO.UserDao(); var result = dao.Login(mode.UserName, SecurityHelper.MD5Hash(mode.UserName + mode.Password)); if (result == 1) { var us = dao.GetUserByUserName(mode.UserName); UserLogin uslog = new UserLogin(); uslog.UserID = us.LoginID; uslog.UserName = us.UserName; uslog.FullName = us.FullName; uslog.Image = us.Image; uslog.LastLogIn = us.LastLogIn; Session[SystemConsts.USER_SESSION] = uslog; dao.LastLogin(us.LoginID, Hepper.GetDateServer()); //if (mode.Remember) //{ // HttpCookie aCookie = new HttpCookie("login"); // aCookie.Values["UserName"] = mode.UserName; // aCookie.Values["Password"] = mode.Password; // aCookie.Expires = DateTime.Now.AddDays(365); // aCookie.Secure = true; // ControllerContext.HttpContext.Response.Cookies.Add(aCookie); //} return(RedirectToAction("Index", "Home")); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại."); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản đã bị khóa."); } else if (result == -2) { ModelState.AddModelError("", "Mật khẩu không đúng"); } } return(View()); }
public ActionResult Create(Builder collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here BuilderDao bdDao = new BuilderDao(); bool kt = true; string taxid = collection.TaxID; if (bdDao.FindByTaxID(taxid) != null) { ModelState.AddModelError("", "Mã số thuế đã tồn tại!"); kt = false; } if (kt == true) { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.BuilderID = bdDao.GenaraCode("NT", 4); collection.CreateDate = Hepper.GetDateServer(); collection.ModifiedDate = Hepper.GetDateServer(); collection.CreateBy = us.UserName; collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection) > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Index(FormCollection data) { try { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; var dao = new FeedbackDao(); long projectID = Convert.ToInt64(data["txtID"].ToString()); ProcessDao prcessDao = new ProcessDao(); ViewBag.lstprocess = prcessDao.ToListProcessUserByProjectID(projectID); ViewBag.lstProjectProcessMessege = prcessDao.GetListProjectProcessMessege(projectID).ToArray <ProjectMessage>(); ViewBag.Messege = prcessDao.CountProcessMessage(projectID).ToString(); Feedback objFeedback = new Feedback(); objFeedback.ProjectID = projectID; objFeedback.Description = data["txtDescription"].ToString(); objFeedback.CreateDate = Hepper.GetDateServer(); objFeedback.ModifiedDate = Hepper.GetDateServer(); objFeedback.CreateBy = us.UserName; objFeedback.ModifiedBy = us.UserName; if (dao.Insert(objFeedback) > 0) { SetAlert("Thêm thành công", "success"); ViewBag.Feedback = dao.ToListFeebBackUser(projectID).ToArray <FeedbackUser>(); List <FeedbackUser> fdnul = new List <FeedbackUser>(); foreach (FeedbackUser fb in ViewBag.Feedback) { if (fb.ChildID == null) { fdnul.Add(fb); } } ViewBag.FeedbackNull = fdnul.ToArray <FeedbackUser>(); return(RedirectToAction("Index")); } } catch { SetAlert("Không thêm được", "danger"); return(View()); } return(View()); }
public JsonResult CreateFeedBack(long projectID, string content, long?chilID = null) { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; Feedback objFeedback = new Feedback(); var dao = new FeedbackDao(); objFeedback.ProjectID = projectID; objFeedback.Description = content; objFeedback.ChildID = chilID; objFeedback.CreateDate = Hepper.GetDateServer(); objFeedback.ModifiedDate = Hepper.GetDateServer(); objFeedback.CreateBy = us.UserName; objFeedback.ModifiedBy = us.UserName; var data = dao.Insert(objFeedback); JsonResult result = new JsonResult(); result.Data = data; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(result); }
public ActionResult Create(MenuType collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuTypeDao bdDao = new MenuTypeDao(); if (bdDao.FindByID(collection.ID) == null) { UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreatedBy = us.UserName; collection.CreatedDate = Hepper.GetDateServer(); collection.ModifiedBy = us.UserName; collection.ModifiedDate = Hepper.GetDateServer(); //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } else { ModelState.AddModelError("", "Mã nhóm menu đã tồn tại"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public JsonResult CreateProcess(long processID, string content, long?chilID = null) { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; MessegeDao msgDao = new MessegeDao(); Messege msg = new Messege(); msg.ChildID = chilID; msg.CreateDate = Hepper.GetDateServer(); msg.ModifiedDate = Hepper.GetDateServer(); msg.CreateBy = us.UserName; msg.ModifiedBy = us.UserName; msg.ProcessID = processID; msg.Description = content; //var list = dao.GetListProjectProcessMessege(projectID); var data = msgDao.Insert(msg); JsonResult result = new JsonResult(); result.Data = data; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(result); }
public ActionResult Create(User collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here UserDao bdDao = new UserDao(); if (bdDao.GetUserByUserName(collection.UserName) != null) { ModelState.AddModelError("", "Tài khoản đã tồn tại!"); return(View()); } // UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; collection.CreatedDate = Hepper.GetDateServer(); collection.LastChangedPassword = Hepper.GetDateServer(); collection.LastLogIn = Hepper.GetDateServer(); collection.Password = Hepper.MD5Hash(collection.UserName + collection.Password); //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection) > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không thêm được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Edit(Menu collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuDao bdDao = new MenuDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.UpdatedBy = us.UserName; collection.UpdatedDate = Hepper.GetDateServer(); MenuDao dbMenu = new MenuDao(); MenuTypeDao dbMenuType = new MenuTypeDao(); var items = GetClientMenuViewModel(); ViewBag.ParentID = new SelectList(items, "ID", "Text"); ViewBag.GroupID = new SelectList(dbMenuType.ToList(), "ID", "Name"); if (bdDao.Update(collection)) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Không cập nhật được", "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Create(Menu collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here MenuDao bdDao = new MenuDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; collection.CreatedBy = us.UserName; collection.CreatedDate = Hepper.GetDateServer(); collection.UpdatedBy = us.UserName; collection.UpdatedDate = Hepper.GetDateServer(); collection.LanguageID = "vi"; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(collection)) { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); } } return(View()); } catch { SetAlert("Không thêm được", "danger"); return(View()); } }
public ActionResult Index(FormCollection data) { long id = Convert.ToInt64(data["txtID"].ToString()); try { UserLogin us = (UserLogin)Session[CommonConstant.USER_SESSION]; var dao = new ProcessDao(); ViewBag.lstProjectProcessMessege = dao.GetListProjectProcessMessege(Convert.ToInt64(data["txtID"].ToString())); ViewBag.lstprocess = dao.ToListProcessUserByProjectID(Convert.ToInt64(data["txtID"].ToString())); Process objProcess = new Process(); string sName = "Giai đoạn " + (dao.ToListByProjectID(id).Count() + 1).ToString(); objProcess.ProjectID = id; // objProcess.Name = data["txtName"].ToString(); objProcess.Name = sName; objProcess.Description = data["txtDescription"].ToString(); objProcess.CreateDate = Hepper.GetDateServer(); objProcess.ModifiedDate = Hepper.GetDateServer(); objProcess.CreateBy = us.UserName; objProcess.ModifiedBy = us.UserName; if (dao.Insert(objProcess) > 0) { SetAlert("Cập nhật tiến độ thành công", Common.CommonConstant.ALERT_SUCCESS); ViewBag.lstprocess = dao.ToListProcessUserByProjectID(Convert.ToInt64(data["txtID"].ToString())); ViewBag.lstProjectProcessMessege = dao.GetListProjectProcessMessege(Convert.ToInt64(data["txtID"].ToString())); return(RedirectToAction("Index", "Process", new { id = id })); } } catch { SetAlert("Không cập nhật được tiến độ", "danger"); return(RedirectToAction("Index", "Process", new { id = id })); } return(View()); }
public ActionResult Create(FormCollection data) { try { if (ModelState.IsValid) { string sTite = data["Tite"].ToString(); string sMetakeyWords = data["MetakeyWords"].ToString(); string sMetaDescription = data["MetaDescription"].ToString(); string sPrepared = data["Prepared"].ToString(); string sOrganization = data["Organization"].ToString(); string sPlace = data["Place"].ToString(); string sDetail = data["Detail"].ToString(); string sImage = data["Image"].ToString(); string sFiles = data["Files"].ToString(); string sOptions = data["Options"].ToString(); string sShowOnHome = data["ShowOnHome"].ToString(); string sStatus_End = data["Status_End"].ToString(); string sDateRate = data["Date_Start"].ToString(); string sDate_Start = sDateRate.Substring(0, sDateRate.IndexOf("-") - 1); string sDate_End = sDateRate.Substring(sDateRate.IndexOf("-") + 1, sDateRate.Length - (sDate_Start.Length + 2)); DateTime Date_Start = Convert.ToDateTime(sDate_Start); DateTime Date_End = Convert.ToDateTime(sDate_End); Calender objCalender = new Calender(); CalenderDao bdDao = new CalenderDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; objCalender.CreateBy = us.UserName; objCalender.CreateDate = Hepper.GetDateServer(); objCalender.ModifiedBy = us.UserName; objCalender.ModifiedDate = Hepper.GetDateServer(); objCalender.PublishDate = Hepper.GetDateServer(); objCalender.Publish = true; objCalender.LanguageID = "vi"; objCalender.GroupID = 1; objCalender.Tite = sTite; objCalender.Place = sPlace; objCalender.Prepared = sPrepared; objCalender.Organization = sOrganization; objCalender.Detail = sDetail; objCalender.MetaDescription = sMetaDescription; objCalender.MetakeyWords = sMetakeyWords; objCalender.Image = sImage; objCalender.Files = sFiles; objCalender.Date_Start = Date_Start; objCalender.Date_End = Date_End; objCalender.Hour_End = Date_End.Hour; objCalender.Minutes_End = Date_End.Minute; objCalender.Hour_Start = Date_Start.Hour; objCalender.Minutes_Start = Date_Start.Minute; objCalender.Options = Convert.ToByte(sOptions); objCalender.ShowOnHome = Convert.ToBoolean(sShowOnHome); objCalender.Status_End = Convert.ToInt32(sStatus_End); objCalender.Status_Start = 0; objCalender.ActiveDate = Hepper.GetDateServer(); objCalender.Active = false; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(objCalender)) { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); } } return(View()); } catch { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); return(View()); } }
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")); } }
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 Create(FormCollection data) { ViewBag.UpTopNew = data["UpTopNew"].ToString(); ViewBag.UpTopHot = data["UpTopHot"].ToString(); PopulateParentIDDropDownList(HepperString.TolistLong(data.GetValues("CategoryID"))); try { News objNews = new News(); NewsDao bdDao = new NewsDao(); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; objNews.Name = data["Name"].ToString(); objNews.Title = data["Title"].ToString(); objNews.MetaTite = data["MetaTite"].ToString(); objNews.MetakeyWords = data["MetakeyWords"].ToString(); objNews.MetaDescription = data["MetaDescription"].ToString(); objNews.Description = data["Description"].ToString(); objNews.ContentHtml = data["ContentHtml"].ToString(); objNews.Image = data["Image"].ToString(); objNews.UpTopNew = Convert.ToDateTime(ViewBag.UpTopNew); objNews.UpTopHot = Convert.ToDateTime(ViewBag.UpTopHot); bool ShowShare = true; if (data.GetValues("ShowShare").Equals("false")) { ShowShare = false; } bool ShowConment = true; if (data.GetValues("ShowConment").Equals("false")) { ShowConment = false; } objNews.ShowShare = ShowShare; objNews.ShowConment = ShowConment; objNews.Source = data["Source"].ToString(); objNews.Status = 0; objNews.CreateDate = Hepper.GetDateServer(); objNews.CreateBy = us.UserName; objNews.ModifiedBy = us.UserName; objNews.Tags = data["Tags"].ToString(); objNews.ModifiedDate = Hepper.GetDateServer(); objNews.LanguageID = "vi"; string[] cateIDs = data.GetValues("CategoryID"); string sCatID = ""; foreach (var sID in cateIDs) { sCatID += sID + ","; } if (sCatID.Length > 0) { sCatID = sCatID.Remove(sCatID.Length - 1, 1); } objNews.CategoryID = sCatID; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Insert(objNews) > 0) { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger"); return(View()); } }