コード例 #1
0
        protected void BtnCalculerSalaire_Click(object sender, EventArgs e)
        {
            string regle = "";

            IDictionary <int, string>[] dictTab   = MyXMLUtilities.GetRegle();
            IDictionary <int, string>   dictSal   = dictTab[0];
            IDictionary <int, string>   dictRemun = dictTab[1];
            IDictionary <int, string>   dictCotis = dictTab[2];
            IDictionary <int, string>   dictArith = dictTab[3];

            for (int i = 0; i < dictSal.Count + dictRemun.Count + dictCotis.Count + dictArith.Count; i++)
            {
                string valeur = "";
                KeyValuePair <int, string> kvp = new KeyValuePair <int, string>();
                kvp = dictSal.Where(x => x.Key == i).FirstOrDefault();
                if (kvp.Value != null)
                {
                    valeur = getInputs(this.TableInfoSalaire, "txt_" + typeof(Salaire))
                             [kvp.Value.Replace(" ", "_")];
                }
                else
                {
                    kvp = dictRemun.Where(x => x.Key == i).FirstOrDefault();
                    if (kvp.Value != null)
                    {
                        valeur = getInputs(this.TableInfoRemun, "txt_" + typeof(Remuneration))
                                 [kvp.Value.Replace(" ", "_")];
                    }
                    else
                    {
                        kvp = dictCotis.Where(x => x.Key == i).FirstOrDefault();
                        if (kvp.Value != null)
                        {
                            valeur = getInputs(this.TableInfoCotis, "txt_" + typeof(Cotisation))
                                     [kvp.Value.Replace(" ", "_")];
                        }
                        else
                        {
                            kvp    = dictArith.Where(x => x.Key == i).FirstOrDefault();
                            valeur = kvp.Value;
                        }
                    }
                }

                regle += valeur;
            }
            DataTable dt = new DataTable();
            string    v  = "";

            try
            {
                v = dt.Compute(regle.Replace(",", "."), "").ToString();
            }
            catch (SyntaxErrorException)
            {
                v = "formule invalide!!";
            }
            this.LblNetAPayer.Text = v.ToString();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["expressionsAttSalaire"]     = new Dictionary <int, string>();
                ViewState["expressionsCotisation"]     = new Dictionary <int, string>();
                ViewState["expressionsRemuneration"]   = new Dictionary <int, string>();
                ViewState["expressionsArithmethiques"] = new Dictionary <int, string>();
                ViewState["expressionsIndice"]         = 0;

                RenderCheckBoxes(typeof(Salaire), this.ChkListAttSalaire);
                RenderCheckBoxes(typeof(Remuneration), this.ChkListRemuneration);
                RenderCheckBoxes(typeof(Cotisation), this.ChkListCotisation);

                foreach (var item in this.DivKeys.Controls)
                {
                    if (item is Button)
                    {
                        ((Button)item).Enabled = false;
                    }
                }
            }
            IDictionary <int, string>[] dictTab   = MyXMLUtilities.GetRegle();
            IDictionary <int, string>   dictSal   = dictTab[0];
            IDictionary <int, string>   dictRemun = dictTab[1];
            IDictionary <int, string>   dictCotis = dictTab[2];
            IDictionary <int, string>   dictArith = dictTab[3];

            for (int i = 0; i < dictSal.Count + dictRemun.Count + dictCotis.Count + dictArith.Count; i++)
            {
                Label lbl = new Label();
                lbl.ID = "lblid" + i;
                KeyValuePair <int, string> kvp = new KeyValuePair <int, string>();
                kvp           = dictSal.Where(x => x.Key == i).FirstOrDefault();
                lbl.ForeColor = System.Drawing.Color.LawnGreen;
                if (kvp.Value == null)
                {
                    kvp           = dictRemun.Where(x => x.Key == i).FirstOrDefault();
                    lbl.ForeColor = System.Drawing.Color.Blue;
                }

                if (kvp.Value == null)
                {
                    kvp           = dictCotis.Where(x => x.Key == i).FirstOrDefault();
                    lbl.ForeColor = System.Drawing.Color.Brown;
                }

                if (kvp.Value == null)
                {
                    kvp           = dictArith.Where(x => x.Key == i).FirstOrDefault();
                    lbl.ForeColor = System.Drawing.Color.DarkSalmon;
                }
                lbl.Text = kvp.Value;
                this.goregle.Controls.Add(lbl);
            }
        }
コード例 #3
0
        protected void BtnSauvgarder_Click(object sender, EventArgs e)
        {
            MyXMLUtilities.UpdateChosenAttributes(typeof(Salaire).Name, getNonDefaultCheckedItems(this.ChkListAttSalaire));
            MyXMLUtilities.UpdateChosenAttributes(typeof(Cotisation).Name, getNonDefaultCheckedItems(this.ChkListCotisation));
            MyXMLUtilities.UpdateChosenAttributes(typeof(Remuneration).Name, getNonDefaultCheckedItems(this.ChkListRemuneration));

            IDictionary <int, string> dict1 = (IDictionary <int, string>)ViewState["expressionsAttSalaire"];
            IDictionary <int, string> dict2 = (IDictionary <int, string>)ViewState["expressionsRemuneration"];
            IDictionary <int, string> dict3 = (IDictionary <int, string>)ViewState["expressionsCotisation"];
            IDictionary <int, string> dict4 = (IDictionary <int, string>)ViewState["expressionsArithmethiques"];
            int count = (int)ViewState["expressionsIndice"];

            MyXMLUtilities.SauvgarderRegle(dict1, dict2, dict3, dict4, count);
            Response.Redirect("~/Interface/GestionSalaire.aspx");
        }
コード例 #4
0
 private void RenderCheckBoxes(Type myEntity, CheckBoxList targetList)
 {
     foreach (var item in myEntity.GetProperties())
     {
         var nomPropriete = item.Name;
         if (item.PropertyType.Namespace.Equals("System") && (!nomPropriete.Equals("Id")))
         {
             ListItem lstitem = new ListItem();
             lstitem.Value = "chkbx" + myEntity + nomPropriete;
             if (MyXMLUtilities.GetAttributes(myEntity.Name, "ByDefaults").Contains(nomPropriete))
             {
                 lstitem.Enabled  = false;
                 lstitem.Selected = true;
             }
             if (MyXMLUtilities.GetAttributes(myEntity.Name, "CheckedAttributes").Contains(nomPropriete))
             {
                 lstitem.Selected = true;
             }
             lstitem.Text = nomPropriete.Replace("_", " ");
             targetList.Items.Add(lstitem);
         }
     }
 }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.LabelDate.Text = DateTime.Now.ToShortDateString();
            string  employeId = Request.QueryString["Id"];
            Employe employe   = this.employeRepository.GetById(Convert.ToInt32(employeId));

            if (employe == null)
            {
                Response.Redirect("~/Interface/GestionSalaire.aspx");
            }
            if (employe.Salaire == null)
            {
                employe.Salaire              = new Salaire();
                employe.Salaire.Cotisation   = new Cotisation();
                employe.Salaire.Remuneration = new Remuneration();
            }
            ViewState["employe"] = employe;
            int gauche_droite = 0;

            foreach (var item in typeof(Employe).GetProperties())
            {
                var nomPropriete    = item.Name;
                var valeurPropriete = item.GetValue(employe);

                if (item.PropertyType.Namespace.Equals("System") && (!nomPropriete.Equals("login") &&
                                                                     (!nomPropriete.Equals("password"))))
                {
                    gauche_droite++;
                    Label lbl_nomPropriete = new Label();
                    lbl_nomPropriete.ID        = "lbl_" + typeof(Employe) + nomPropriete;
                    lbl_nomPropriete.Text      = nomPropriete.Replace("_", " ");
                    lbl_nomPropriete.Font.Bold = true;

                    Label lbl_valeurPropriete = new Label();
                    lbl_valeurPropriete.ID   = "txt_" + typeof(Employe) + nomPropriete;
                    lbl_valeurPropriete.Text = valeurPropriete?.ToString();

                    TableRow  tr;
                    TableCell tc1 = new TableCell();
                    TableCell tc2 = new TableCell();
                    tc1.Controls.Add(lbl_nomPropriete);
                    tc2.Controls.Add(lbl_valeurPropriete);

                    if (gauche_droite % 2 != 0)
                    {
                        tr = new TableRow();
                        tr.Cells.Add(tc1);
                        tr.Cells.Add(tc2);
                        this.TableInfoEmploye.Rows.Add(tr);
                    }
                    else
                    {
                        tr = this.TableInfoEmploye.Rows[this.TableInfoEmploye.Rows.Count - 1];
                        tr.Cells.Add(tc1);
                        tr.Cells.Add(tc2);
                    }
                }
            }

            gauche_droite = 0;
            foreach (var item in typeof(Salaire).GetProperties())
            {
                var nomPropriete    = item.Name;
                var valeurPropriete = item.GetValue(employe.Salaire);
                if (item.PropertyType.Namespace.Equals("System") && (!nomPropriete.Equals("Id")) &&
                    (MyXMLUtilities.GetAttributes(typeof(Salaire).Name).Contains(nomPropriete)))
                {
                    gauche_droite++;
                    Label lbl_nomPropriete = new Label();
                    lbl_nomPropriete.ID        = "lbl_" + typeof(Salaire) + nomPropriete;
                    lbl_nomPropriete.Text      = nomPropriete.Replace("_", " ");
                    lbl_nomPropriete.Font.Bold = true;

                    TextBox txt_valeurPropriete = new TextBox();
                    txt_valeurPropriete.ID   = "txt_" + typeof(Salaire) + nomPropriete;
                    txt_valeurPropriete.Text = valeurPropriete?.ToString();
                    txt_valeurPropriete.Attributes.Add("class", "form-control");


                    RegularExpressionValidator rv = new RegularExpressionValidator();
                    rv.ControlToValidate    = txt_valeurPropriete.ID;
                    rv.ErrorMessage         = "erreur!!";
                    rv.ForeColor            = System.Drawing.Color.Red;
                    rv.ValidationExpression = @"(^\d{1,18}\,\d{1,2}$)|(^\d{1,18}$)";

                    TableRow  tr;
                    TableCell tc1 = new TableCell();
                    TableCell tc2 = new TableCell();
                    tc1.Controls.Add(lbl_nomPropriete);
                    tc2.Controls.Add(txt_valeurPropriete);
                    tc2.Controls.Add(rv);
                    if (gauche_droite % 2 != 0)
                    {
                        tr = new TableRow();
                        tr.Cells.Add(tc1);
                        tr.Cells.Add(tc2);
                        this.TableInfoSalaire.Rows.Add(tr);
                    }
                    else
                    {
                        tr = this.TableInfoSalaire.Rows[this.TableInfoSalaire.Rows.Count - 1];
                        tr.Cells.Add(tc1);
                        tr.Cells.Add(tc2);
                    }
                }
            }

            foreach (var item in typeof(Remuneration).GetProperties())
            {
                var nomPropriete    = item.Name;
                var valeurPropriete = item.GetValue(employe.Salaire.Remuneration);
                if (item.PropertyType.Namespace.Equals("System") && (!nomPropriete.Equals("Id")) &&
                    (MyXMLUtilities.GetAttributes(typeof(Remuneration).Name).Contains(nomPropriete)))
                {
                    Label lbl_nomPropriete = new Label();
                    lbl_nomPropriete.ID        = "lbl_" + typeof(Remuneration) + nomPropriete;
                    lbl_nomPropriete.Text      = nomPropriete.Replace("_", " ");
                    lbl_nomPropriete.Font.Bold = true;

                    TextBox txt_valeurPropriete = new TextBox();
                    txt_valeurPropriete.ID   = "txt_" + typeof(Remuneration) + nomPropriete;
                    txt_valeurPropriete.Text = valeurPropriete?.ToString();
                    txt_valeurPropriete.Attributes.Add("class", "form-control");

                    RegularExpressionValidator rv = new RegularExpressionValidator();
                    rv.ControlToValidate    = txt_valeurPropriete.ID;
                    rv.ErrorMessage         = "erreur!!";
                    rv.ForeColor            = System.Drawing.Color.Red;
                    rv.ValidationExpression = @"(^\d{1,18}\,\d{1,2}$)|(^\d{1,18}$)";

                    TableRow  tr  = new TableRow();
                    TableCell tc1 = new TableCell();
                    TableCell tc2 = new TableCell();
                    tc1.Controls.Add(lbl_nomPropriete);
                    tc2.Controls.Add(txt_valeurPropriete);
                    tc2.Controls.Add(rv);
                    tr.Cells.Add(tc1);
                    tr.Cells.Add(tc2);
                    this.TableInfoRemun.Rows.Add(tr);
                }
            }

            foreach (var item in typeof(Cotisation).GetProperties())
            {
                var nomPropriete    = item.Name;
                var valeurPropriete = item.GetValue(employe.Salaire.Cotisation);
                if (item.PropertyType.Namespace.Equals("System") && (!nomPropriete.Equals("Id")) &&
                    (MyXMLUtilities.GetAttributes(typeof(Cotisation).Name).Contains(nomPropriete)))
                {
                    Label lbl_nomPropriete = new Label();
                    lbl_nomPropriete.ID        = "lbl_" + typeof(Cotisation) + nomPropriete;
                    lbl_nomPropriete.Text      = nomPropriete.Replace("_", " ");
                    lbl_nomPropriete.Font.Bold = true;

                    TextBox txt_valeurPropriete = new TextBox();
                    txt_valeurPropriete.ID   = "txt_" + typeof(Cotisation) + nomPropriete;
                    txt_valeurPropriete.Text = valeurPropriete.ToString();
                    txt_valeurPropriete.Attributes.Add("class", "form-control");

                    RegularExpressionValidator rv = new RegularExpressionValidator();
                    rv.ControlToValidate    = txt_valeurPropriete.ID;
                    rv.ErrorMessage         = "erreur!!";
                    rv.ForeColor            = System.Drawing.Color.Red;
                    rv.ValidationExpression = @"(^\d{1,18}\,\d{1,2}$)|(^\d{1,18}$)";

                    TableRow  tr  = new TableRow();
                    TableCell tc1 = new TableCell();
                    TableCell tc2 = new TableCell();
                    tc1.Controls.Add(lbl_nomPropriete);
                    tc2.Controls.Add(txt_valeurPropriete);
                    tc2.Controls.Add(rv);
                    tr.Cells.Add(tc1);
                    tr.Cells.Add(tc2);
                    this.TableInfoCotis.Rows.Add(tr);
                }
            }
        }