private void SaveCour_Click(object sender, EventArgs e) { //On masque les pannel transition.HideSync(panelAjoutCour); panelAjoutCour.Visible = false; transition.HideSync(modifCourrier); modifCourrier.Visible = false; transition.HideSync(panelExp); panelExp.Visible = false; nomExpe = nomE.text; prenExpe = prenomExp.text; telExpe = telExp.text; //Création des objets à sauvegarder dans la bd Expediteur E = new Expediteur(nomExpe, prenExpe, telExpe); MessageBox.Show(txtType.Items[txtType.selectedIndex + 3]); Courrier C = new Courrier(reference, libelle, contenu, txtType.Items[txtType.selectedIndex + 3], nomExpe); //Déclarattion de la clase qui va sqauvegarder le courrier GestionnaireConnexion Connect = new GestionnaireConnexion(); Connect.InsertCourrier(C, E); //On actualise le contenu Actualiser(); }
public ActionResult DeleteConfirmed(int id) { Courrier courrier = db.Courrier.Find(id); db.Courrier.Remove(courrier); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Sujet,Expiditeur,Destinataire,Message,CourDate,TypeId")] Courrier courrier) { if (ModelState.IsValid) { db.Entry(courrier).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courrier)); }
public async Task <IHttpActionResult> GetCourrier(string id) { Courrier courrier = courrierService.GetById(id); if (courrier == null) { return(NotFound()); } return(Ok(courrier)); }
public ActionResult Create([Bind(Include = "ID,Sujet,Expiditeur,Destinataire,Message,CourDate,TypeId")] Courrier courrier) { if (ModelState.IsValid) { db.Courrier.Add(courrier); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(courrier)); }
protected override void Seed(GedPiDevContext context) { var listCategories = new Courrier() { ObjetCourrier = "email" }; context.courriers.Add(listCategories); context.SaveChanges(); }
public async Task <IHttpActionResult> PostCourrier(Courrier Courrier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } courrierService.Add(Courrier); courrierService.CommitAsync(); return(CreatedAtRoute("DefaultApi", new { id = Courrier.CourrierId }, Courrier)); }
public async Task <IHttpActionResult> DeleteCourrier(string id) { Courrier Courrier = courrierService.GetById(id); if (Courrier == null) { return(NotFound()); } courrierService.Delete(Courrier); courrierService.CommitAsync(); return(Ok(Courrier)); }
// GET: /Courrier/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Courrier courrier = db.Courrier.Find(id); if (courrier == null) { return(HttpNotFound()); } return(View(courrier)); }
public async Task <IHttpActionResult> PutCourrier(string id, Courrier Courrier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != Courrier.CourrierId) { return(BadRequest()); } courrierService.Update(Courrier); courrierService.CommitAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Uploadxml(HttpPostedFileBase file) { if (Request.Files["file"].ContentLength > 0) { DataSet ds = new DataSet(); string extension = System.IO.Path.GetExtension(Request.Files["file"].FileName); if (extension.ToString().ToLower().Equals(".xml")) { string fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["file"].SaveAs(fileLocation); XmlTextReader xmlreader = new XmlTextReader(fileLocation); ds.ReadXml(xmlreader); xmlreader.Close(); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Courrier messages = new Courrier { Sujet = ds.Tables[0].Rows[i][0].ToString(), Destinataire = ds.Tables[0].Rows[i][1].ToString(), Expiditeur = ds.Tables[0].Rows[i][2].ToString(), Message = ds.Tables[0].Rows[i][3].ToString(), CourDate = DateTime.Parse(ds.Tables[0].Rows[i][4].ToString()), Type = ds.Tables[0].Rows[i][5].ToString() }; db.Courrier.Add(messages); db.SaveChanges(); } } return(RedirectToAction("Index")); }
public CourrierViewModel(Courrier courrier) : base(courrier) { }
protected CourrierDecorator(Courrier courrier) { this._courrier = courrier; }
public ActionResult Index(HttpPostedFileBase file) { DataSet ds = new DataSet(); if (Request.Files["file"].ContentLength > 0) { string fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName); if (fileExtension == ".xls" || fileExtension == ".xlsx") { string FileName = System.IO.Path.GetFileName(Request.Files["file"].FileName); string FolderPath = ConfigurationManager.AppSettings["FolderPath"]; string fileLocation = Server.MapPath(FolderPath + FileName); //string fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["file"].SaveAs(fileLocation); string excelConnectionString = string.Empty; excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; //connection String for xls file format. if (fileExtension == ".xls") { excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""; } //connection String for xlsx file format. else if (fileExtension == ".xlsx") { excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; } //Create Connection to Excel work book and add oledb namespace OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); excelConnection.Open(); DataTable dt = new DataTable(); dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null) { return(null); } String[] excelSheets = new String[dt.Rows.Count]; int t = 0; //excel data saves in temp file here. foreach (DataRow row in dt.Rows) { excelSheets[t] = row["TABLE_NAME"].ToString(); t++; } OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString); string query = string.Format("Select * from [{0}]", excelSheets[0]); using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, excelConnection1)) { dataAdapter.Fill(ds); } } if (fileExtension.ToString().ToLower().Equals(".xml")) { string fileLocation = Server.MapPath("~/Content/") + Request.Files["FileUpload"].FileName; if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["FileUpload"].SaveAs(fileLocation); XmlTextReader xmlreader = new XmlTextReader(fileLocation); // DataSet ds = new DataSet(); ds.ReadXml(xmlreader); xmlreader.Close(); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { /* string conn = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString; * SqlConnection con = new SqlConnection(conn); * string query = "Insert into Person(Name,Email,Mobile) Values('" + ds.Tables[0].Rows[i][0].ToString() + "','" + ds.Tables[0].Rows[i][1].ToString() + "','" + ds.Tables[0].Rows[i][2].ToString() + "')"; * con.Open(); * SqlCommand cmd = new SqlCommand(query, con); * cmd.ExecuteNonQuery(); * con.Close();*/ Courrier messages = new Courrier { Sujet = ds.Tables[0].Rows[i][0].ToString(), Destinataire = ds.Tables[0].Rows[i][1].ToString(), Expiditeur = ds.Tables[0].Rows[i][2].ToString(), Message = ds.Tables[0].Rows[i][3].ToString(), CourDate = DateTime.Parse(ds.Tables[0].Rows[i][4].ToString()), Type = ds.Tables[0].Rows[i][5].ToString() }; db.Courrier.Add(messages); db.SaveChanges(); } } return(RedirectToAction("Index")); }