public static void AddDepense(T_Depense p_newDep) { CoEco_BDDataContext bd = new CoEco_BDDataContext(); bd.T_Depense.InsertOnSubmit(p_newDep); bd.SubmitChanges(); bd.Dispose(); }
public static T_Depense GetDepenseById(int id) { CoEco_BDDataContext bd = new CoEco_BDDataContext(); T_Depense t = bd.T_Depense.Single(f => f.idDepense == id); bd.Dispose(); return(t); }
public static void ApprouverDepenseByID(int id, bool etat) { CoEco_BDDataContext bd = new CoEco_BDDataContext(); T_Depense dep = bd.T_Depense.Single(f => f.idDepense == id); dep.aprobation = etat; bd.SubmitChanges(); bd.Dispose(); }
public static void UpdateDepense(T_Depense depense) { CoEco_BDDataContext bd = new CoEco_BDDataContext(); T_Depense depenseToMod = bd.T_Depense.Single(p => p.idDepense == depense.idDepense); depenseToMod.idProjet = depense.idProjet; //depenseToMod.idCategorie = depense.idCategorie; depenseToMod.idType = depense.idType; depenseToMod.descript = depense.descript; depenseToMod.montant = depense.montant; depenseToMod.ddate = depense.ddate; depenseToMod.idEmp = depenseToMod.idEmp; depenseToMod.aprobation = depense.aprobation; bd.SubmitChanges(); bd.Dispose(); }
protected void btn_desapprouver_Click(object sender, EventArgs e) { if (Request.QueryString["Type"].ToString() == "1") { T_Depense actuDep = BD_CoEco.GetDepenseById(int.Parse(Request.QueryString["id"])); actuDep.aprobation = false; BD_CoEco.UpdateDepense(actuDep); Response.Redirect("DepenseAdmin.aspx"); } else { T_Kilometrage actuKilo = BD_CoEco.GetKiloById(int.Parse(Request.QueryString["id"])); actuKilo.approbation = false; BD_CoEco.UpdateKilometrage(actuKilo); Response.Redirect("DepenseAdmin.aspx"); } }
//appliquer la modification d'une dépense protected void btn_apply_Click(object sender, EventArgs e) { if (Request.QueryString["Type"].ToString() == "1") { T_Depense newDep = new T_Depense(); newDep.idDepense = int.Parse(Request.QueryString["id"]); newDep.montant = decimal.Parse(tbx_montant.Text); newDep.descript = tbx_description.Text; if (Ddate != null) { newDep.ddate = DateTime.Parse(Ddate.Text); } newDep.idType = int.Parse(ddl_typeDepense.SelectedValue); newDep.idProjet = int.Parse(ddl_projet.SelectedValue); //newDep.idCategorie = int.Parse(ddL_categorie.SelectedValue); newDep.idEmp = int.Parse(ddl_employe.SelectedValue); newDep.aprobation = null; BD_CoEco.UpdateDepense(newDep); } else { T_Kilometrage kilo = new T_Kilometrage(); kilo.idKilo = int.Parse(Request.QueryString["id"].ToString()); kilo.approbation = null; kilo.idEmp = int.Parse(ddl_employe.SelectedValue); kilo.idPro = int.Parse(ddl_projet.SelectedValue); kilo.ddate = DateTime.Parse(Ddate.Text); kilo.commentaire = tbx_description.Text; kilo.nbKilo = float.Parse(tbx_montant.Text); kilo.idTaux = int.Parse(ddl_typeVehicule.SelectedValue); BD_CoEco.UpdateKilometrage(kilo); } if (Session["fonction"].ToString() != "3") { Response.Redirect("DepenseEMP.aspx"); } else { Response.Redirect("DepenseAdmin.aspx"); } }
private void afficherDepense() { ddl_projet.Enabled = false; //ddL_categorie.Enabled = false; ddl_typeDepense.Enabled = false; tbx_description.Enabled = false; tbx_description.Enabled = false; tbx_montant.Enabled = false; Ddate.Enabled = false; ddl_employe.Enabled = false; string id = Request.QueryString["id"]; string type = Request.QueryString["Type"]; if (type == "1") { T_Depense depense = BD_CoEco.GetDepenseById(int.Parse(id)); ddl_projet.SelectedValue = depense.idProjet.ToString(); //loadDdlCat(); // ddL_categorie.SelectedValue = BD_CoEco.GetCatByID((int)depense.idCategorie).idCategorie.ToString(); //ddL_categorie.SelectedValue = depense.idCategorie.ToString(); ddl_typeDepense.SelectedValue = depense.idType.ToString(); tbx_description.Text = depense.descript; tbx_montant.Text = depense.montant.ToString(); Ddate.Text = string.Format("{0:yyyy-MM-dd}", depense.ddate); ddl_employe.SelectedValue = depense.idEmp.ToString(); } else { T_Kilometrage kilo = BD_CoEco.GetKiloById(int.Parse(id)); ddl_projet.SelectedValue = kilo.idPro.ToString(); //loadDdlCat(); ddl_typeDepense.SelectedValue = "-1"; tbx_description.Text = kilo.commentaire; tbx_montant.Text = kilo.nbKilo.ToString(); ddl_typeVehicule.SelectedValue = BD_CoEco.GetTauxKiloById(kilo.idTaux).idTypeAuto.ToString(); div_KM.Visible = true; ddl_typeVehicule.Enabled = false; lbl_MontantOuKm.InnerText = "Total km"; Ddate.Text = string.Format("{0:yyyy-MM-dd}", kilo.ddate); ddl_employe.SelectedValue = kilo.idEmp.ToString(); } }
public void ApprouverDep(object sender, EventArgs e) { CheckBox cbx_toApp = (CheckBox)sender; int id = int.Parse(cbx_toApp.ID.Split('-')[1]); int type = int.Parse(cbx_toApp.ID.Split('-')[2]); if (type == 1) { //Depense T_Depense dep = BD_CoEco.GetDepenseById(id); dep.aprobation = cbx_toApp.Checked; BD_CoEco.UpdateDepense(dep); } else { T_Kilometrage kilo = BD_CoEco.GetKiloById(id); kilo.approbation = cbx_toApp.Checked; BD_CoEco.UpdateKilometrage(kilo); } }
//bouton ajouter en tant qu'Admin protected void btn_ok_ServerClick(object sender, EventArgs e) { if (Session["fonction"].ToString() != "3") { try { if (ddl_typeDepense.SelectedValue != "-1") { T_Depense newDep = new T_Depense(); newDep.montant = decimal.Parse(tbx_montant.Text); newDep.descript = tbx_description.Text; newDep.ddate = DateTime.Parse(Ddate.Text); newDep.idType = int.Parse(ddl_typeDepense.SelectedValue); newDep.idProjet = int.Parse(ddl_projet.SelectedValue); newDep.idEmp = int.Parse(Session["idEmp"].ToString()); newDep.aprobation = null; BD_CoEco.AddDepense(newDep); } else { //Kilométrage T_Kilometrage newKilo = new T_Kilometrage(); newKilo.nbKilo = float.Parse(tbx_montant.Text); newKilo.commentaire = tbx_description.Text; newKilo.ddate = DateTime.Parse(Ddate.Text); newKilo.idEmp = int.Parse(Session["idEmp"].ToString()); newKilo.idPro = int.Parse(ddl_projet.SelectedValue); newKilo.idTaux = BD_CoEco.GetIdTauxKilo(int.Parse(ddl_typeVehicule.SelectedValue)); BD_CoEco.AjouterDepKilometrage(newKilo); } } catch (Exception ex) { } Response.Redirect("DepenseEMP.aspx"); } else //ajouter une dépense en tant qu'admin { if (ddl_typeDepense.SelectedValue != "-1") { T_Depense newDep = new T_Depense(); if (tbx_montant.Text != "") { newDep.montant = decimal.Parse(tbx_montant.Text); } if (tbx_description.Text != "") { newDep.descript = tbx_description.Text; } if (Ddate.Text != "") { newDep.ddate = DateTime.Parse(Ddate.Text); } newDep.idType = int.Parse(ddl_typeDepense.SelectedValue); newDep.idProjet = int.Parse(ddl_projet.SelectedValue); //newDep.idCategorie = int.Parse(ddL_categorie.SelectedValue); newDep.idEmp = int.Parse(ddl_employe.SelectedValue); newDep.aprobation = null; BD_CoEco.AddDepense(newDep); } else { //Kilométrage T_Kilometrage newKilo = new T_Kilometrage(); if (tbx_montant.Text != "") { newKilo.nbKilo = float.Parse(tbx_montant.Text); } if (tbx_description.Text != "") { newKilo.commentaire = tbx_description.Text; } if (Ddate.Text != "") { newKilo.ddate = DateTime.Parse(Ddate.Text); } newKilo.idEmp = int.Parse(ddl_employe.SelectedValue); //Cette partie à retirer / modifier newKilo.idPro = int.Parse(ddl_projet.SelectedValue); //newKilo.idCat = int.Parse(ddL_categorie.SelectedValue); newKilo.idTaux = BD_CoEco.GetIdTauxKilo(int.Parse(ddl_typeVehicule.SelectedValue)); BD_CoEco.AjouterDepKilometrage(newKilo); } Response.Redirect("DepenseAdmin.aspx"); } }