Esempio n. 1
0
        protected void BTNADDArch_Click(object sender, EventArgs e)
        {
            if (TitreArch.Value != "" || textArea.InnerHtml != "" || EmpPc.Value != "" || index.Value != "" || selectTypeAroo.SelectedValue != "" ||
                ArchiveUpload.HasFile)
            {
                String ext = System.IO.Path.GetExtension(ArchiveUpload.FileName);
                if (ext == ".pdf" || ext == ".docx" || ext == ".png")
                {
                    idU = Int32.Parse(Session["idUser"].ToString());
                    Utilisateur u           = new ActionsUtilisateur().rechercheUtilisateurParId(idU);
                    String      titreAr     = TitreArch.Value;
                    String      description = textArea.InnerHtml;
                    DateTime    day         = DateTime.Now;
                    int         idType      = 0;
                    Int32.TryParse(selectTypeAroo.SelectedValue, out idType);
                    Fichier f = new Fichier();
                    f.Nom              = titreAr;
                    f.Description      = description;
                    f.dateAjout        = day;
                    f.extention        = ext;
                    f.dateModification = day;
                    f.dateDernierAcces = day;
                    f.index            = index.Value;
                    f.emplacementPC    = EmpPc.Value;
                    f.dateSuppression  = day;
                    ActionsType actionsType = new ActionsType();
                    f.idType = idType;
                    f.type   = actionsType.getTypeById(idType);
                    int id = new ActionsFichier().ajouterParUser(u, f);
                    f.idFichier = id;
                    f.chemain   = Server.MapPath("~/Archives/" + "archive-" + id + ".pdf");
                    new ActionsFichier().modifier(f);
                    ArchiveUpload.SaveAs(Server.MapPath("~/Archives/" + "archive-" + id + ".pdf"));

                    String indexmsg = "index du archive ajoute est : " + f.index + "";

                    Response.Redirect("./Calendrier.aspx?indexmsg=" + indexmsg);
                }
                else
                {
                    erreur.InnerHtml = "Le fichier doit etre format pdf,img,docx seulement";
                }
            }
            else
            {
                erreur.InnerHtml = "veuillez remplir tous les champs";
            }
        }
        protected void BTNADDArch_Click(object sender, EventArgs e)
        {
            if (TitreArch.Value != "" || textArea.InnerHtml != "" || EmpPc.Value != "" || index.Value != "" || selectTypeAroo.SelectedValue != "")
            {
                Fichier f = new Fichier();



                String   titreAr     = TitreArch.Value;
                String   description = textArea.InnerHtml;
                DateTime day         = DateTime.Now;
                int      idType      = 0;
                Int32.TryParse(selectTypeAroo.SelectedValue, out idType);

                f.Nom              = titreAr;
                f.Description      = description;
                f.dateAjout        = day;
                f.dateModification = day;
                f.dateDernierAcces = day;
                f.index            = index.Value;
                f.emplacementPC    = EmpPc.Value;
                f.dateSuppression  = day;
                if (CKRC.Checked)
                {
                    f.commArch = 0;
                }
                else
                {
                    f.commArch = 1;
                }
                ActionsType actionsType = new ActionsType();
                f.type = actionsType.getTypeById(idType);
                int id = new ActionsFichier().ajouterF(f);
                f.idFichier = id;
                if (!CKCE.Checked)
                {
                    String ext = System.IO.Path.GetExtension(ArchiveUpload.FileName);
                    f.extention = ext;
                    if (ext == ".pdf" || ext == ".doc" || ext == ".png")
                    {
                        f.chemain = Server.MapPath("~/Archives/" + "archive-" + id + ".pdf");
                        ArchiveUpload.SaveAs(Server.MapPath("~/Archives/" + "archive-" + id + ".pdf"));
                    }
                    else
                    {
                        erreur.InnerHtml = "veuillez remplir tous les champs";
                        Response.Redirect("./AjouterArchiveAdmin.aspx");
                    }
                }
                new ActionsFichier().modifier(f);


                String indexmsg = "index du archive ajoute est : " + f.index + "";

                Response.Redirect("./CalendrierAdmin.aspx?indexmsg=" + indexmsg);
            }
            else
            {
                erreur.InnerHtml = "veuillez remplir tous les champs";
            }
        }