/// <summary> /// Si les modifications sont valides change l'article concerné à l'appuie sur le bouton valider /// </summary> /// <param name="Sender"></param> /// <param name="Event"></param> private void OkButton_Click(object Sender, EventArgs Event) { // verifie que le prix puis la quantité soient bien des nombres double DoublePrice; if (double.TryParse(PriceHTTextBox.Text, out DoublePrice)) { int IntQuantity; if (int.TryParse(QuantityTextBox.Text, out IntQuantity)) { // vérifie que les champs soient remplie if (DescriptionTextBox.Text != "" && PriceHTTextBox.Text != "" && QuantityTextBox.Text != "" && BrandComboBox.Text != "" && FamilyComboBox.Text != "" && SubFamilyComboBox.Text != "") { ArticleDAO.EditArticle(ArticleNameLabel.Text, DescriptionTextBox.Text, (SubFamily)SubFamilyComboBox.SelectedItem, (Brand)BrandComboBox.SelectedItem, (float)DoublePrice, IntQuantity); this.Close(); } else { MessageBox.Show("Les champs doivent etre remplient", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("La quantite doit etre un nombre", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Le prix doit etre un nombre", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ModifierPlat(int idPlat) { InitializeComponent(); this.idTransferred = idPlat; dao = new ArticleDAO(); a = dao.getById(idTransferred); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Keyboard.Focus(txtNomPlat); txtprix.Text = a.Prix.ToString(); txtNomPlat.Text = a.Libelle.ToString(); ArticleDAO daoa = new ArticleDAO(); if (a.IdCategorie.Equals(1)) { cmbType.SelectedIndex = 0; } else if (a.IdCategorie.Equals(2)) { cmbType.SelectedIndex = 1; } else if (a.IdCategorie.Equals(5)) { cmbType.SelectedIndex = 2; } else if (a.IdCategorie.Equals(3)) { cmbType.SelectedIndex = 4; } else if (a.IdCategorie.Equals(4)) { cmbType.SelectedIndex = 5; } }
public MainController() { ArticleDao = new ArticleDAO(); MarqueDao = new MarqueDAO(); FamilleDao = new FamilleDAO(); SousFamilleDao = new SousFamilleDAO(); }
//type = 0 : Lecture X //type = 1 : lecture Z public LectureExcel(int type) { this.type = type; error = 0; try { listUsedDepartements = new List <Departement>(); caTTCDep = new List <float>(); listUsedTypePaiement = PayementDAO.listSommePaiementToday(1); DepartmentTTC(ArticleDAO.selectArticlePayeeByDateNoCleanWay(1)); List <Commande> listCommandeRecuToday = CommandeDAO.listCommandeRecuToday(1); listUsedTypeArticle = new List <string>(); reçutArticle = new List <int>(); renduArticle = new List <int>(); TypeArticlesRendu(ArticleDAO.selectArticleRenduByDate(1), listCommandeRecuToday); nbNewCommande = listCommandeRecuToday.Count; nbNewClient = ClientDAO.listClientAddToday(1).Count; } catch (Exception e) { if (error == 0) { MessageBox.Show("Erreur dans la récupération des données pour l'impression de la facture: /n" + e); } error = 1; } }
public ActionResult Avatar(string ACCOUNT_Username, HttpPostedFileBase ACCOUNT_Avatar) { if (ModelState.IsValid) { ACCOUNT aCCOUNT = new ACCOUNT(); aCCOUNT.ACCOUNT_Username = ACCOUNT_Username; var dao = new LoginDAO().GetByUsername(ACCOUNT_Username); if (ACCOUNT_Avatar != null) { string fileName = new ArticleDAO().GetCode(dao.ACCOUNT_Name); string extension = Path.GetExtension(ACCOUNT_Avatar.FileName); fileName += extension; string Url = "/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/" + fileName; fileName = Path.Combine(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/"), fileName); if (!Directory.Exists(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/"))) { Directory.CreateDirectory(Server.MapPath("~/Content/dist/img/" + dao.ACCOUNT_Id + "/Avatar/")); } ACCOUNT_Avatar.SaveAs(fileName); aCCOUNT.ACCOUNT_Avatar = Url; if (new LoginDAO().Avatar(aCCOUNT)) { SetAlert("Profile has been changed successfully!", "success"); } } else { SetAlert("Profile change failed, please try again!", "warning"); } } return(RedirectToAction("Index")); }
private void RecommendHandler2(long id, ArticleSettingModels setting, string uploadUrl, IEnumerable <ArticleTypesModels> types) { if (setting.ExtendReadOpen2) { IEnumerable <ArticleModels> recommends = ArticleDAO.GetRecommendItems2(setting, id, types.Select(t => t.ID)); Dictionary <long, SitePage> recommendSitePages = CardsDAO.GetPages(recommends.Select(r => r.CardNo)); Dictionary <long, dynamic> imgPathInfo = new Dictionary <long, dynamic>(); imgPathInfo.Add(setting.MenuID, new { Setting = setting, UploadUrl = uploadUrl }); foreach (ArticleModels item in recommends) { SitePage page = recommendSitePages[item.CardNo]; dynamic pathInfo; if (!imgPathInfo.TryGetValue(page.MenuID, out pathInfo)) { ArticleSettingModels newSetting = ArticleSettingDAO.GetItem(page.MenuID); string newUploadUrl = UpdFileInfo.GetVPathByMenuID(page.SiteID, page.MenuID).TrimEnd('/') + "/"; pathInfo = new { Setting = newSetting, UploadUrl = newUploadUrl }; imgPathInfo.Add(page.MenuID, pathInfo); } string img = item.GetFirstImg(pathInfo.Setting); item.Icon = string.IsNullOrWhiteSpace(img) ? string.Empty : pathInfo.UploadUrl + img; } ViewBag.Recommends2 = recommends; ViewBag.RecommendSitePages2 = recommendSitePages; } }
public ActionResult Files(string filter = null, string ARTICLES_UploadTimeStart = null, string ARTICLES_UploadTimeFinish = null) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var model = new ArticleDAO().MyUpload(session.UserID, filter, ARTICLES_UploadTimeStart, ARTICLES_UploadTimeFinish); return(View(model)); }
public ActionResult Render(long SiteID, long ZoneNo) { List <ImageTextModel> imageTextList = new List <ImageTextModel>(); var Zone = CardsDAO.GetZoneInfo(ZoneNo); var Cards = CardsDAO.GetZoneData(SiteID, ZoneNo); string RenderViewFileName = "~/Views/Article/ImageTextListStyleDefault.cshtml"; if (Cards != null && Cards.Count > 0) { foreach (CardsModels Card in Cards) { if (Card.CardsType == "Article") { WorkV3.Common.SitePage curPage = WorkV3.Models.DataAccess.CardsDAO.GetPage(Card.No); ViewBag.UploadVPath = UpdFileInfo.GetVPathByMenuID(curPage.SiteID, curPage.MenuID); var article = ArticleDAO.GetItemByCard(Card.No); if (article != null) { imageTextList = ImageTextDAO.Get(article.ID, true, null); string ViewFileName = string.Format("~/Views/Article/ImageTextListStyle{0}.cshtml", Card.StylesID.ToString()); if (System.IO.File.Exists(Server.MapPath(ViewFileName))) { RenderViewFileName = ViewFileName; } } } } } return(View(RenderViewFileName, imageTextList)); }
public override async Task <Article> UnfavoriteArticle(string authedUsername, string slug) { var transaction = _context.Database.BeginTransaction(); try { IdentityUser user = await _userManager.FindByNameAsync(authedUsername); ArticleDAO articleDao = await _articleRepository.GetArticleBySlug(slug); _favoriteArticleRepository.UnfavoriteArticle(articleDao.Id, user.Id); _context.SaveChanges(); articleDao = await _articleRepository.GetArticleBySlug(slug); transaction.Commit(); Article article = await CreateArticleFromDAO(articleDao, authedUsername); return(article); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
private void RendreCommande() { //Les articles passent en rendus //TODO //MessageBox.Show("Réglage de la commande"); if (ClasseGlobale._renduCommandeClientPro != null) { Commande cmd = ClasseGlobale._renduCommandeClientPro; cmd = CommandeDAO.selectCommandeById(cmd.id, true, true, true); //Parcours de la liste d'article et update de la bdd foreach (Article art in cmd.listArticles) { //On update l'emplacment convoyeur art.convoyeur.encombrement -= art.type.encombrement; PlaceConvoyeurDAO.updatePlaceConvoyeur(art.convoyeur); //Puis l'article art.date_rendu = DateTime.Now; art.ifRendu = true; art.convoyeur = null; ArticleDAO.updateArticle(art); } cmd.date_rendu = DateTime.Now; CommandeDAO.updateCommande(cmd); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["currentUser"] == null) { Response.Redirect("Login.aspx"); } else { User currentUser = (User)Session["currentUser"]; Boolean authenticate = authenticateAccess(currentUser); if (!authenticate) { Response.Redirect("errorPage.aspx"); } else { if (!IsPostBack) { string id = Request.QueryString["id"]; int id_num = Convert.ToInt32(id); ArticleDAO adao = new ArticleDAO(); a = adao.getArticleById(id_num); txtTitle.Text = a.article_name; CKEditor1.Text = a.article_body; } } } }
public ActionResult File(string Id) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var model = new ArticleDAO().GetByFileName(session.UserID, Id); return(View(model)); }
public ActionResult DeleteArticle(int id) { ArticleDAO articleDAO = new ArticleDAO(); articleDAO.DeleteArticle(id); return(Redirect("/Home/Articles/")); }
public ActionResult Index(string msg) { ViewModel mymodel = new ViewModel(); mymodel.AllPosts = ArticleDAO.List(); return(View(mymodel)); }
public override async Task <Article> CreateArticle(string authedUsername, NewArticle newArticle) { var transaction = _context.Database.BeginTransaction(); try { IdentityUser author = await _userManager.FindByNameAsync(authedUsername); String authorId = author.Id; ArticleDAO createdArticle = _articleRepository.CreateArticle( title: newArticle.Title, description: newArticle.Description, body: newArticle.Body, authorId: authorId); _context.SaveChanges(); List <TagDAO> tags = _tagsRepository.SaveTags(newArticle.TagList); _context.SaveChanges(); _articleTagsRepository.SaveArticleTags(tags.Select(e => e.Id).ToList(), createdArticle.Id); _context.SaveChanges(); Article article = await CreateArticleFromDAO(createdArticle, authedUsername); transaction.Commit(); return(article); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
private async Task <Article> CreateArticleFromDAO(ArticleDAO articleDAO, String authedUsername) { try { IdentityUser user = null; if (null != authedUsername) { user = await _userManager.FindByNameAsync(authedUsername); } IdentityUser author = await _userManager.FindByIdAsync(articleDAO.AuthorId); return(new Article { Author = await _profileService.GetProfile(author.UserName, authedUsername), Body = articleDAO.Body, CreatedAt = articleDAO.CreatedAt, Description = articleDAO.Description, Favorited = _favoriteArticleRepository.IsArticleFavorited(articleDAO.Id, user?.Id), FavoritesCount = _favoriteArticleRepository.GetFavoritesCountForArticle(articleDAO.Id), Slug = articleDAO.Slug, TagList = _articleTagsRepository.GetTagListForArticle(articleDAO.Id), Title = articleDAO.Title, UpdatedAt = articleDAO.UpdatedAt }); } catch (Exception ex) { throw ex; } }
public void Copy(long siteId, long menuId, long[] ArticleIds, long TargetMenuID) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.ActionType = "copy"; if (ArticleIds.Length == 0) { return; } var targetMenu = MenusDAO.GetInfo(TargetMenuID); foreach (long ArticleId in ArticleIds) { ArticleModels articleItem = ArticleDAO.GetItem(ArticleId); CardsModels cardItem = CardsDAO.GetByNo(articleItem.CardNo); ZonesModels zoneItem = ZonesDAO.GetByNo(cardItem.ZoneNo.Value); PagesModels pageItem = PagesDAO.GetPageInfo(zoneItem.PageNo); long newCardNo = WorkV3.Golbal.PubFunc.CopyPage(pageItem, targetMenu.SiteID, targetMenu.ID); long newArticleId = WorkLib.GetItem.NewSN(); bool IsForceRelative = false; if (pageItem.SiteID == targetMenu.SiteID && pageItem.MenuID == targetMenu.ID) { IsForceRelative = true; } ArticleDAO.CopyArticle(ArticleId, newArticleId, newCardNo, targetMenu.ID, targetMenu.SiteID, IsForceRelative); WorkV3.Golbal.PubFunc.CopyIcon(articleItem.Icon, siteId, menuId, targetMenu.SiteID, targetMenu.ID); WorkV3.Golbal.PubFunc.CopyParagraphPhotos(articleItem.ID, siteId, menuId, targetMenu.SiteID, targetMenu.ID); } }
/// <summary> /// Filtra los resultados mostrados en la tabla según el parámetro ingresado, dicha búsqueda se realiza /// ya sea por clave o por nombre. /// </summary> /// <param name="parameter"></param> /// Contiene el valor a buscar. public void filterResults(string parameter) { dgvArticles.Rows.Clear(); for (int i = 0; i < articlesList.Count; i++) { if (rbtnNameArticle.Checked == true) { if (articlesList[i].Name.ToLower().Contains(parameter) == true) { dgvArticles.Rows.Add(articlesList[i].IdArticle, articlesList[i].Name, articlesList[i].Quantity); } } else if (rbtnIdArticle.Checked == true) { if ((articlesList[i].IdArticle + "").Contains(parameter) == true) { dgvArticles.Rows.Add(articlesList[i].IdArticle, articlesList[i].Name, articlesList[i].Quantity); } } } if (dgvArticles.RowCount == 0) { pnlDetails.Visible = false; } else { selectedItem = ArticleDAO.getOneById(int.Parse(dgvArticles.Rows[0].Cells[0].Value + "")); index = 0; fillDetails(selectedItem, index); dgvArticles.Rows[index].Selected = true; } }
public AjoutPlat(string tbSel) { InitializeComponent(); dao = new ArticleDAO(); a = new Article(); this.tbSel = tbSel; }
/// <summary> /// Elimina el artículo seleccionado. /// </summary> private void btnDelete_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("¿Está seguro que desea eliminar el artículo?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } if (selectedItem.Image != null) { var newFilepath = Path.Combine(Common.Util.GetSolutionFolder(), "Common", "Resources\\Articles", selectedItem.Image); if (myComputer.FileSystem.FileExists(newFilepath)) { myComputer.FileSystem.DeleteFile(newFilepath); } } ArticleDAO.deleteById(selectedItem.IdArticle); updateTable(); cleanPanelAddEdit(); pnlAddEdit.Visible = false; pnlDetails.Visible = false; isEmpty(); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { var homePage = new ArticleDAO { Id = 1, Topic = "Home Page", Slug = "home-page", Content = "This is the default home page. Please change me!", Published = Instant.FromDateTimeUtc(new DateTime(2018, 6, 19, 14, 31, 2, 265, DateTimeKind.Utc)), AuthorId = Guid.Empty }; var homePageHistory = ArticleHistoryDAO.FromArticle(homePage); homePageHistory.Id = 1; homePageHistory.Article = null; modelBuilder.Entity <ArticleDAO>(entity => { entity.HasIndex(a => a.Slug).IsUnique(); entity.HasData(homePage); }); modelBuilder.Entity <ArticleHistoryDAO>(entity => { entity.HasData(homePageHistory); }); modelBuilder.Entity <SlugHistoryDAO>(entity => { entity.HasIndex(a => new { a.OldSlug, a.AddedDateTime }); }); }
/// <summary> /// Supprime l'élement sélectionné du bon tableau /// </summary> /// <param name="NodeName"></param> /// <param name="SelectedItem"></param> private void DeleteItemListView(String NodeName, ListViewItem SelectedItem) { switch (NodeName) { case "Articles": ArticleDAO.DeleteArticle(SelectedItem.SubItems[2].Text); UpdateListView("Articles"); break; case "Marques": BrandDAO.DeleteBrand(int.Parse(SelectedItem.SubItems[1].Text)); UpdateListView("Marques"); break; case "Familles": FamilyDAO.DeleteFamily(int.Parse(SelectedItem.SubItems[1].Text)); UpdateListView("Familles"); break; case "Sous familles": SubFamilyDAO.DeleteSubFamily(int.Parse(SelectedItem.SubItems[1].Text)); UpdateListView("Sous familles"); break; default: break; } }
public override async Task <Comment> CreateComment(string username, string commentBody, string articleSlug) { var transaction = _context.Database.BeginTransaction(); try { DateTime now = DateTime.Now; ArticleDAO article = await _articleRepository.GetArticleBySlug(articleSlug); int articleId = article.Id; IdentityUser user = await _userManager.FindByNameAsync(username); string authorId = user.Id; CommentDAO commentDao = _commentRepository.CreateComment(commentBody, authorId, articleId); _context.SaveChanges(); Comment comment = await CreateCommentFromDAO(commentDao, username); transaction.Commit(); return(comment); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
public ActionResult PosterSelect(long siteId, long menuId, long articleId) { ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; IEnumerable <ArticlePosterModels> items = ArticlePosterDAO.GetIssueItems(menuId); string uploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/"; foreach (ArticlePosterModels p in items) { if (!string.IsNullOrWhiteSpace(p.Photo)) { ResourceImagesModels photo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(p.Photo); if (photo.Img != string.Empty) { p.Photo = uploadUrl + photo.Img; } } } IEnumerable <long> curPosterIds = ArticleDAO.GetItemPosters(articleId).Select(p => p.ID); if (curPosterIds == null) { curPosterIds = new List <long>(); } ViewBag.Posters = curPosterIds; ViewBag.Int64Converter = new WorkV3.Golbal.Int64Converter(); return(View(items)); }
public void ArticleDel(long siteId, long menuId, IEnumerable <long> ids) { foreach (long id in ids) { SysLog.SaveArticleDelLog(id); } ArticleDAO.Delete(ids); }
public ActionResult ViewPost(int id) { if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(View(ArticleDAO.Detail(id))); }
public ActionResult Create() { ViewModel model = new ViewModel(); model.AllPosts = ArticleDAO.List(); model.AllCategories = CategoryDAO.List(); return(View()); }
public ActionResult Update(long id) { SetViewBag(); SetUserName(); var post = new ArticleDAO().GetArticleByID(id); return(View(post)); }
public ActionResult ChangeArticle(string Section, Article article) { ArticleDAO articleDAO = new ArticleDAO(); articleDAO.ChangeArticle(Section, article); return(RedirectToAction("Index")); }