1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
|
public class NouveauBilan : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlInputFile fichier;
protected System.Web.UI.WebControls.Button bt_enregistrer;
protected System.Web.UI.WebControls.Button bt_annuler;
protected System.Web.UI.WebControls.Button bt_transmis;
protected System.Web.UI.WebControls.Button bt_creer;
protected GestionBilans gb = new GestionBilans();
protected GestionWorkflow gw = new GestionWorkflow();
protected System.Web.UI.HtmlControls.HtmlInputHidden confirm_sup;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.Label Label14;
protected System.Web.UI.WebControls.Label Label15;
protected System.Web.UI.WebControls.CheckBox rex;
protected System.Web.UI.WebControls.CheckBox sox;
protected System.Web.UI.WebControls.CheckBox cisi;
protected System.Web.UI.WebControls.TextBox nom_projet;
protected System.Web.UI.WebControls.TextBox nom_createur;
protected System.Web.UI.WebControls.TextBox nom_cdpl;
protected System.Web.UI.WebControls.TextBox date;
protected System.Web.UI.WebControls.DropDownList list_dcs;
protected System.Web.UI.WebControls.DropDownList list_sb;
protected System.Web.UI.WebControls.TextBox codeRP;
protected System.Web.UI.WebControls.TextBox debutRex;
protected System.Web.UI.WebControls.TextBox finRex;
protected System.Web.UI.WebControls.DropDownList list_DCS;
protected System.Web.UI.WebControls.DropDownList list_SB;
protected System.Web.UI.WebControls.Label label;
protected System.Web.UI.WebControls.CheckBox cmmi;
protected System.Web.UI.WebControls.RequiredFieldValidator Require1;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator1;
protected System.Web.UI.WebControls.Label titre;
protected Piece p = new Piece();
protected System.Web.UI.WebControls.Button bt_ajouter;
protected System.Web.UI.WebControls.RadioButtonList pieces;
protected System.Web.UI.WebControls.Button bt_dwl;
protected System.Web.UI.WebControls.Button bt_supprimer;
protected System.Web.UI.WebControls.Panel Panel_pieces;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label etat;
protected System.Web.UI.WebControls.Label test;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
public String etat_bilan = "0";
private void Page_Load(object sender, System.EventArgs e)
{
AX.ADN.IS.WacSecurity.Principal.WacPrincipal utilisateur =
(AX.ADN.IS.WacSecurity.Principal.WacPrincipal)Page.User;
String matricule = utilisateur.Identity.Name;
Session["utilisateur"] = matricule;
DateTime d = DateTime.Now;
date.Text = Convert.ToString(d);
nom_createur.Text = recup_nom(matricule.ToLower());
recupListe(list_DCS,gb.ListeDCS());
recupListe(list_SB,gb.ListeSB());
ucBouton.BoutonCreerClick += new EventHandler(ucBouton_BoutonCreerClick);
ucBouton.BoutonAnnulerClick += new EventHandler(ucBouton_BoutonAnnulerClick);
ucBouton.BoutonSauverClick +=new EventHandler(ucBouton_BoutonSauverClick);
ucBouton.BoutonTAnalyserClick += new EventHandler(ucBouton_BoutonTAnalyserClick);
ucBouton.BoutonTValiderClick += new EventHandler(ucBouton_BoutonTValiderClick);
ucBouton.BoutonValiderClick += new EventHandler(ucBouton_BoutonValiderClick);
bt_supprimer.Attributes.Add("onClick","return confirmSup();");
}
private String recup_nom(String matricule)
{
GestionBilans gb = new GestionBilans();
for(int i=0;i<gb.ListePersonnes().Tables[0].Rows.Count;i++)
{
if(gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(0).ToString()==matricule)
{
return gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(2).ToString()
+ " " + gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(1).ToString();
}
}
return "";
}
public void recupListe(DropDownList dl,DataSet ds)
{
dl.DataSource = ds;
dl.DataTextField = "nom";
dl.DataValueField ="nom";
dl.DataBind();
}
#region Code généré par le Concepteur Web Form
override protected void OnInit(EventArgs e)
{
EnableViewState = false;
InitializeComponent();
Bouton ucBouton = (Bouton)LoadControl("Bouton.ascx",etat_bilan,1) ;
PlaceHolder1.Controls.Add(ucBouton);
base.OnInit(e);
}
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private UserControl LoadControl(string UserControlPath, params object[] constructorParameters)
{
ArrayList constParamTypes = new ArrayList();
foreach (object constParam in constructorParameters)
{
constParamTypes.Add(constParam.GetType()) ;
}
object[] o = constParamTypes.ToArray();
Type[] t = new Type[o.Length];
for (int i = 0; i < o.Length; i++)
{
t[i] = (Type)o[i];
}
UserControl ctl = Page.LoadControl(UserControlPath) as UserControl;
// Find the relevant constructor
ConstructorInfo constructor = ctl.GetType().BaseType.GetConstructor(t) ;
//And then call the relevant constructor
if (constructor == null)
{
throw new MemberAccessException("The requested constructor was not found on : " + ctl.GetType().BaseType.ToString()) ;
}
else
{
constructor.Invoke(ctl,constructorParameters) ;
}
// Finally return the fully initialized UC
return ctl;
}
public static string conv(bool val)
{
if(val) return "oui";
else return "non";
}
private void bt_ajouter_Click(object sender, System.EventArgs e)
{
string nom_fichier;
String matricule = (String)Session["utilisateur"];
int idbe = Convert.ToInt32(Session["idbe"]);
if (fichier.PostedFile.FileName.Length != 0)
{
string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
nom_fichier=fichier.PostedFile.FileName.Substring(fichier.PostedFile.FileName.LastIndexOf(@"\") + 1);
p = gb.AjouterPiece(idbe,matricule.ToLower(),nom_fichier);
fichier.PostedFile.SaveAs(monchemin + p.Nom_pj);
pieces.Items.Add(nom_fichier);
pieces.Items[pieces.Items.Count-1].Value = p.Idpj.ToString();
Session["idpj"] = p.Idpj;
Session["nom_pj"] = p.Nom_pj;
Session["list_piece"] = gb.ListePiece(idbe);
/*bt_supprimer.Visible = true;
bt_dwl.Visible = true;*/
}
}
private void bt_supprimer_Click(object sender, System.EventArgs e)
{
int idpj = Convert.ToInt32(Session["idpj"]);
int idbe = Convert.ToInt32(Session["idbe"]);
string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
if(confirm_sup.Value == "ok" && pieces.Items.Count !=0 && pieces.SelectedItem != null)
{
File.Delete(monchemin + gb.RecupNomStrockee(idbe,pieces.SelectedItem.Text));
gb.SupprimerPiece(Convert.ToInt32(pieces.SelectedValue));
pieces.Items.Remove(pieces.SelectedItem);
}
}
private void bt_dwl_Click(object sender, System.EventArgs e)
{
string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
int idbe = Convert.ToInt32(Session["idbe"]);
string filename = System.Configuration.ConfigurationSettings.AppSettings["eSignServer_RootPath"] + monchemin + gb.RecupNomStrockee(idbe,pieces.SelectedItem.Text);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
Response.Clear();
Response.AppendHeader("Content-Disposition","attachment; filename="+fileInfo.Name);
Response.AppendHeader("Content-Length",fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fileInfo.FullName);
Response.End();
}
private void ucBouton_BoutonAnnulerClick(object sender, EventArgs e)
{
Response.Redirect("Accueil.aspx");
}
private void ucBouton_BoutonCreerClick(object sender, EventArgs e)
{
String matricule = (String)Session["utilisateur"];
Regex rexValideur = new Regex("[a-zA-Z]+");
if(rexValideur.IsMatch(nom_projet.Text) && rexValideur.IsMatch(nom_cdpl.Text))
{
//epErrorProvider.SetError(nom_projet, "");
int idbe= gb.CreationBilan(matricule.ToLower(),nom_projet.Text,nom_createur.Text,
nom_cdpl.Text,DateTime.Now,list_DCS.SelectedIndex + 1,
list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
codeRP.Text = idbe.ToString();
Session["idbe"] = idbe;
etat_bilan = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["creation"]),matricule.ToLower()).ToString();
}
}
private void envoie_mail()
{
MailMessage message=new MailMessage();
message.From="frank.berrih@axa.fr";
message.To="frank.berrih@axa.fr";
//if(subject=="analyse")
message.Subject = ConfigurationSettings.AppSettings["subject_analyse"];// + Session["idbe"].ToString;
/*if(subject=="analyse")
message.Subject = ConfigurationSettings.AppSettings["subject_analyse"] + Session["idbe"].ToString;*/
StringBuilder chaine=new StringBuilder();
chaine.Append("<b>Erreur sur le site</b><br><br>");
/*chaine.Append("Détails : <br><br>");
chaine.Append("Date : "+DateTime.Now.Tostring()+"<br><br>");
chaine.Append("Pile : "+ex.StackTrace.Tostring()+"<br><br>");
chaine.Append("Source : "+ex.Source.Tostring()+"<br><br>");
chaine.Append("Url :"+Request.Url.Tostring()); */
message.BodyFormat=MailFormat.Html;
message.Priority=MailPriority.High;
message.Body=chaine.ToString();
SmtpMail.SmtpServer="localhost";
SmtpMail.Send(message);
}
private void ucBouton_BoutonTAnalyserClick(object sender, EventArgs e)
{
envoie_mail();
}
private void ucBouton_BoutonTValiderClick(object sender, EventArgs e)
{
}
private void ucBouton_BoutonValiderClick(object sender, EventArgs e)
{
}
private void b_BoutonSauverClick(object sender, EventArgs e)
{
String matricule = (String)Session["utilisateur"];
int idbe = Convert.ToInt32(Session["idbe"]);
gb.ModifierBilan(idbe,nom_projet.Text,nom_cdpl.Text,list_DCS.SelectedIndex + 1,
list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
String etat = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["enregistrement"]),matricule.ToLower()).ToString();
/*Bouton b1 = (Bouton)LoadControl("Bouton.ascx",etat,1) ;
//ucBouton.Controls.Clear();
ucBouton.Controls.Add(b1);*/
}
private void ucBouton_BoutonSauverClick(object sender, EventArgs e)
{
String matricule = (String)Session["utilisateur"];
int idbe = Convert.ToInt32(Session["idbe"]);
gb.ModifierBilan(idbe,nom_projet.Text,nom_cdpl.Text,list_DCS.SelectedIndex + 1,
list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
String etat = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["enregistrement"]),matricule.ToLower()).ToString();
}
}
} |
Partager