partial void DeleteMessage(Message instance);
partial void UpdateMessage(Message instance);
partial void InsertMessage(Message instance);
private void detach_Message(Message entity) { this.SendPropertyChanging(); entity.Encodage = null; }
private void attach_Message(Message entity) { this.SendPropertyChanging(); entity.Encodage = this; }
protected void EcrireSMS(object sender, EventArgs e) { Message msg = new Message(); if (ListeMode.SelectedValue == "Texte") { // Il s'agit d'un message texte //insertion d'un message msg.messageTexte = contenuSMS.Text; msg.noDestinataire = numDestinataire.Text; //on recupere l'encodage msg.Encodage = (from enc in dbContext.Encodage where enc.idEncodage == int.Parse(DropDownEncodage.SelectedValue) select enc).First(); //demande accuse reception if (CheckBoxAccuse.Checked) // on a demande un accuse { msg.accuseReception = 1; } else { msg.accuseReception = 0; } } else { // Message PDU msg.messagePDU = contenuSMS.Text; // Encodage PDU msg.Encodage = (from enc in dbContext.Encodage where enc.idEncodage == 4 select enc).First(); } dbContext.Message.InsertOnSubmit(msg); //on cree un message envoi MessageEnvoi smsEnvoi = new MessageEnvoi(); smsEnvoi.Message = msg; smsEnvoi.dateDemande = DateTime.Now; //selectionne statut en attente Statut stat = (from st in dbContext.Statut where st.libelleStatut == "En attente" select st).First(); smsEnvoi.Statut = stat; if (ListeMode.SelectedValue == "Texte") { int nbJours, nbHeures, nbMinutes; if (tbJours.Text == null || tbJours.Text=="") nbJours = 0; else nbJours = int.Parse(tbJours.Text); if (tbHeures.Text == null || tbHeures.Text=="") nbHeures = 0; else nbHeures = int.Parse(tbHeures.Text); if (tbMinutes.Text == null || tbMinutes.Text == "") nbMinutes = 5; else { nbMinutes = int.Parse(tbMinutes.Text); if (nbMinutes < 5) nbMinutes = 5; } //duree de validite TimeSpan duree = new TimeSpan(nbJours, nbHeures, nbMinutes, 0, 0); if (duree.Days > 30) //Up to 441 days smsEnvoi.dureeValidite = (byte)(192 + (int)(duree.Days / 7)); else if (duree.Days >= 1) //Up to 30 days smsEnvoi.dureeValidite = (byte)(166 + duree.Days); else if (duree.Hours > 12) //Up to 24 hours smsEnvoi.dureeValidite = (byte)(143 + (duree.Hours - 12) * 2 + duree.Minutes / 30); else if (duree.Hours >= 1 || duree.Minutes > 1) //Up to 12 hours smsEnvoi.dureeValidite = (byte)(duree.Hours * 12 + duree.Minutes / 5 - 1); else smsEnvoi.dureeValidite = 0; } dbContext.MessageEnvoi.InsertOnSubmit(smsEnvoi); dbContext.SubmitChanges(); Response.Write("<script> $(\"#dialog\").dialog(); </script>"); }