using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using eWorld.UI; using OutilsGeneraux; public partial class _Services : System.Web.UI.Page { protected EffUser effuser { get { return (EffUser)Session["EffUser"]; } } protected int serviceid; protected DateTime ExitDate; string MeteoProjetGlobalstring = string.Empty; string CommentairesProjetGlobalstring = string.Empty; protected override void OnPreInit(EventArgs e) { if (Request.Form["ServiceId"] != null) serviceid = int.Parse(Request.Form["ServiceId"]); else if (Request.Form["ctl00$Appli$DDL_ServiceId"] != null) serviceid = int.Parse(Request.Form["ctl00$Appli$DDL_ServiceId"]); else if (Request.QueryString["ServiceId"] != null) serviceid = int.Parse(Request.QueryString["ServiceId"]); else { if (effuser.ServiceEnCours != null) { serviceid = effuser.ServiceEnCours.ServiceId; } else { if (effuser.EtatMajor != true) { Server.Transfer("droitsInsuffisants.aspx", false); } else { serviceid = 999; } } } if (Request.Form["MeteoProjetGlobal"]!=null) MeteoProjetGlobalstring = Request.Form["MeteoProjetGlobal"]; if (Request.Form["ctl00$Appli$CommentairesProjetGlobal"] != null) CommentairesProjetGlobalstring = Request.Form["ctl00$Appli$CommentairesProjetGlobal"]; if (effuser.ListeService.Contains(serviceid.ToString())) effuser.ServiceEnCours = new Service(serviceid); else Server.Transfer("droitsInsuffisants.aspx", false); base.OnPreInit(e); } protected void Page_Load(object sender, EventArgs e) { ServiceIDHidden.Text = serviceid.ToString(); } protected string RenvoieNomResponsable(string vf) { return (new Personne(vf, Global.ChaineDeConnexionALAnnuaire)).Nom; } protected void AfficheMiseAJourProjetGlobal(object sender, ImageClickEventArgs e) { CommentairesProjetGlobal.Disabled = false; ModeNormalProjetGlobal.Visible = false; ModeEditionProjetGlobal.Visible = true; ValidProjetGlobal.Visible = true; AnnuleProjetGlobal.Visible = true; ButtonAfficheMiseAJourProjetGlobal.Visible = false; TableProjetGlobal.BgColor = "#E0E0E0"; } protected void ValidMiseAJourProjetGlobal(object sender, ImageClickEventArgs e) { string sql = string.Empty; if (CommentairesProjetGlobalstring != null && MeteoProjetGlobalstring != null) { sql = string.Format(@"UPDATE tbl_services set Meteo={0}, CommentairesProjet='{1}' where serviceId={2}", MeteoProjetGlobalstring, CommentairesProjetGlobalstring.Replace("'", "''"), serviceid); SqlConnection ObjConnection = new SqlConnection(Global.ChaineDeConnexionALApplication); ObjConnection.Open(); SqlCommand ObjCommand = new SqlCommand(); ObjCommand.Connection = ObjConnection; ObjCommand.CommandText = sql; ObjCommand.ExecuteNonQuery(); ObjCommand.Dispose(); ObjConnection.Dispose(); effuser.ServiceEnCours = new Service(serviceid); } else { Response.Write("Erreur lors de la mise à jour"); } CommentairesProjetGlobal.Disabled = true; ModeNormalProjetGlobal.Visible = true; ModeEditionProjetGlobal.Visible = false; ValidProjetGlobal.Visible = false; AnnuleProjetGlobal.Visible = false; ButtonAfficheMiseAJourProjetGlobal.Visible = true; TableProjetGlobal.BgColor = "white"; } protected void AnnuleMiseAJourProjetGlobal(object sender, ImageClickEventArgs e) { CommentairesProjetGlobal.Disabled = true; ModeNormalProjetGlobal.Visible = true; ModeEditionProjetGlobal.Visible = false; ValidProjetGlobal.Visible = false; AnnuleProjetGlobal.Visible = false; ButtonAfficheMiseAJourProjetGlobal.Visible = true; TableProjetGlobal.BgColor = "white"; } protected void AfficheMiseAJourActionGlobal(object sender, ImageClickEventArgs e) { CommentairesActionGlobal.Disabled = false; ValidActionGlobal.Visible = true; AnnuleActionGlobal.Visible = true; ButtonAfficheMiseAJourActionGlobal.Visible = false; TableActionGlobal.BgColor = "#E0E0E0"; } protected void ValidMiseAJourActionGlobal(object sender, ImageClickEventArgs e) { string sql = string.Empty; sql = string.Format(@"UPDATE tbl_services set CommentairesAction='{0}' where serviceId={1}", Request.Form["ctl00$Appli$CommentairesActionGlobal"].Replace("'", "''"), serviceid); SqlConnection ObjConnection = new SqlConnection(Global.ChaineDeConnexionALApplication); ObjConnection.Open(); SqlCommand ObjCommand = new SqlCommand(); ObjCommand.Connection = ObjConnection; ObjCommand.CommandText = sql; ObjCommand.ExecuteNonQuery(); ObjCommand.Dispose(); ObjConnection.Dispose(); effuser.ServiceEnCours = new Service(serviceid); CommentairesActionGlobal.Disabled = true; ValidActionGlobal.Visible = false; AnnuleActionGlobal.Visible = false; ButtonAfficheMiseAJourActionGlobal.Visible = true; TableActionGlobal.BgColor = "white"; } protected void AnnuleMiseAJourActionGlobal(object sender, ImageClickEventArgs e) { CommentairesActionGlobal.Disabled = true; ValidActionGlobal.Visible = false; AnnuleActionGlobal.Visible = false; ButtonAfficheMiseAJourActionGlobal.Visible = true; TableActionGlobal.BgColor = "white"; } protected override void OnPreRender(EventArgs e) { CommentairesProjetGlobal.Value = effuser.ServiceEnCours.CommentairesProjet; CommentairesActionGlobal.Value = effuser.ServiceEnCours.CommentairesAction; if (!effuser.EtatMajor) { DirectionLien.Visible = false; } if (serviceid == 999) { TableProjetGlobal.Visible = false; Grid_Actions.Visible = false; TableActionGlobal.Visible = false; Grid_Projets.Visible = false; } DDL_ServiceId.SelectedValue = effuser.ServiceEnCours.ServiceId.ToString(); base.OnPreRender(e); } protected string AfficheStatut(object actionterminee, DateTime? dateprevue, DateTime? datesaisie) { bool actiontermineebool = false; bool.TryParse(actionterminee.ToString(), out actiontermineebool); string imagetemp = string.Empty; if (actiontermineebool) { imagetemp = "images/carrevert.gif"; } else { if (datesaisie == DateTime.Parse("01/01/1901 00:00:00")) { if (DateTime.Today > dateprevue) { imagetemp = "images/carrerouge.gif"; } else { imagetemp = "images/carregris.gif"; } } else { if (DateTime.Today > datesaisie) { imagetemp = "images/carrerouge.gif"; } else { imagetemp = "images/carregris.gif"; } } } return imagetemp; } protected DateTime? DBNulltest(object testval) { if (!(System.Convert.IsDBNull(testval))) { return (DateTime?)testval; } else { return null; } } protected void ChangeNull(object sender, EventArgs e) { CalendarPopup cp = (CalendarPopup)sender; if (cp.SelectedDate == DateTime.Parse("01/01/1901 00:00:00")) cp.SelectedValue = null; else if (System.Convert.IsDBNull(cp.SelectedDate)) cp.SelectedValue = null; } protected void AlternNull(object sender, GridViewUpdateEventArgs e) { object truc = sender; GridView gv = (GridView)sender; GridViewRow row = gv.Rows[e.RowIndex]; CalendarPopup cpDebut = (CalendarPopup)row.FindControl("DateDebutSaisie"); if (cpDebut.SelectedValue == null) e.NewValues["DateDebutSaisie"] = DateTime.Parse("01/01/1901"); CalendarPopup cpFin = (CalendarPopup)row.FindControl("DateFinSaisie"); if (cpFin.SelectedValue == null) e.NewValues["DateFinSaisie"] = DateTime.Parse("01/01/1901"); } protected void Inserevaleur(object sender, EventArgs e) { ServiceIDHidden.Text = serviceid.ToString(); } protected void InsereValeurVF(object sender, EventArgs e) { VfUser.Text = effuser.VF; } protected void DDL_ServiceId_PreRender(object sender, EventArgs e) { if (!IsPostBack) { DDL_ServiceId.Items.Insert(0, new ListItem("Choisir un service", "999")); } } }