Exemple #1
0
        private void buttonX4_Click(object sender, EventArgs e)
        {
            // Bouton Ok suppression
            buttonX5.Visible  = true;
            buttonX1.Visible  = false;
            buttonX2.Visible  = false;
            buttonX3.Visible  = false;
            buttonX4.Visible  = false;
            buttonX6.Visible  = true;
            buttonX7.Visible  = true;
            buttonX8.Visible  = true;
            buttonX11.Visible = true;
            label4.Text       = "";
            String msg = MessageBox.Show("Ete-vous sur", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();

            if (msg.Equals("Yes"))
            {
                String req = "DELETE FROM utilisateur Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];
                if (met.Execute(req))
                {
                    MessageBox.Show("Suppression effectuée");
                }
            }
            util_Load(sender, e);
        }
Exemple #2
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            // Bouton Sauver
            if (superValidator1.Validate())
            {
                if (!modif)
                {
                    String req = "INSERT INTO modalite(codes,code,libelle,Observation) Values ('" + Program.Societe + "','" + textBox1.Text + "', '" + textBox2.Text + "','" + textBox3.Text.Replace("'", "\\'") + "')";
                    if (met.Execute(req))
                    {
                        MessageBox.Show("Sauvgarde effectué");
                    }
                    String req1 = "SELECT * FROM modalite where codes='" + Program.Societe + "'  Order by code ";
                    ds = met.recuperer_table(req1);
                    afficheb();
                    affiche();
                }
                else
                {
                    Boolean test = true;
                    if (!textBox1.Text.Equals(ds.Tables[0].Rows[index].Field <object>("code")))
                    {
                        String  sql   = "SELECT code FROM modalite where codes='" + Program.Societe + "'";
                        DataSet verif = met.recuperer_table(sql);
                        if (verif.Tables[0].Rows.Count != 0)
                        {
                            test = false;
                        }
                    }
                    if (test)
                    {
                        // Mode Modification
                        String req = "Update modalite Set codes='" + Program.Societe + "',code = '" + textBox1.Text + "', libelle = '" + textBox2.Text + "',Obsertvation='" + textBox3.Text.Replace("'", "\\'") + "' Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                        if (met.Execute(req))
                        {
                            MessageBox.Show("Sauvgarde effectué");
                        }

                        modif = false;

                        String req1 = "SELECT * FROM modalite where codes='" + Program.Societe + "'  Order by code ";
                        ds = met.recuperer_table(req1);
                        afficheb();
                        affiche();
                        this.buttonX6.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Code déja existant");
                    }
                }
            }
        }
Exemple #3
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                String req = "Update pnum Set dlivraison = '" + t1.Text
                             + "', livraison = '" + t2.Text
                             + "', dcomande = '" + t3.Text
                             + "', comande = '" + t4.Text
                             + "', ddevis = '" + t5.Text
                             + "', devis = '" + t6.Text
                             + "', dcomandef = '" + t11.Text
                             + "', comandef = '" + t12.Text
                             + "', dregcli = '" + t7.Text
                             + "', regcli = '" + t8.Text
                             + "', dentre = '" + t9.Text
                             + "', entre = '" + t10.Text
                             + "', dregfour = '" + t13.Text
                             + "', regfour = '" + t14.Text
                             + "', dbon = '" + t15.Text
                             + "', bon = '" + t16.Text
                             + "' Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                if (met.Execute(req))
                {
                    MessageBox.Show("Sauvgarde effectué");
                }

                Pnum_Load(sender, e);
                this.buttonX1.Focus();
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #4
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (superValidator1.Validate())
            {
                // Bouton Sauver
                toolStrip1.Visible   = true;
                toolStrip2.Visible   = false;
                toolStrip3.Visible   = false;
                textBox1.ReadOnly    = true;
                textBox2.ReadOnly    = true;
                radioButton1.Enabled = false;
                radioButton2.Enabled = false;

                button1.Visible = true;
                button2.Visible = true;
                button3.Visible = true;
                button4.Visible = true;

                if (!modif)
                {
                    // Mode création
                    //(Access) string S = "#"+dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day + "/" + dateTimePicker1.Value.Year + "#";
                    //(Mysql) string S =  + dateTimePicker1.Value.Month + "-" + dateTimePicker1.Value.Day + "-" + dateTimePicker1.Value.Year;
                    String req = "INSERT INTO tva(libelle, taux, actif) Values ('" + textBox1.Text + "', " + textBox2.Text + ", " + radioButton1.Checked + ")";
                    if (met.Execute(req))
                    {
                        MessageBox.Show("Sauvgarde effectué");
                    }
                    tva_Load(sender, e);
                }
                else
                {
                    // Mode Modification
                    String req = "Update tva Set Libelle = '" + textBox1.Text + "', taux = " + textBox2.Text + ", actif = " + radioButton1.Checked + " Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];
                    if (met.Execute(req))
                    {
                        MessageBox.Show("Sauvgarde effectué");
                    }
                    modif = false;
                    tva_Load(sender, e);
                }
            }
        }
Exemple #5
0
        private void buttonX4_Click(object sender, EventArgs e)
        {
            // Bouton Ok suppression
            buttonX5.Visible  = true;
            buttonX1.Visible  = false;
            buttonX2.Visible  = false;
            buttonX3.Visible  = false;
            buttonX4.Visible  = false;
            buttonX6.Visible  = true;
            buttonX7.Visible  = true;
            buttonX8.Visible  = true;
            buttonX11.Visible = true;
            label12.Text      = "";
            String msg = MessageBox.Show("Etes-vous sûr de Supprimer ", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();

            if (msg.Equals("Yes"))
            {
                String req = "DELETE FROM Client Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                if (met.Execute(req))
                {
                    MessageBox.Show("Suppression effectuée");
                }
            }
            string req5 = "SELECT * FROM client WHERE codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "' Order by code";

            ds = met.recuperer_table(req5, "client");

            if (index > 1)
            {
                index--;
            }
            else
            {
                index = 0;
            }
            affiche();
            afficheb();
        }
Exemple #6
0
 private void buttonX9_Click(object sender, EventArgs e)
 {
     if (superValidator1.Validate())
     {
         DateTime datej = DateTime.Now;
         int      Xnbj  = 0;
         int.TryParse(nbj.Text, out Xnbj);
         xdate = datej.AddDays(Xnbj);
         String req = "Update propos Set imaged = '" + xdate.ToString("yyyy-MM-dd") + "', imagef = '21011966' ";
         met.Execute(req);
         MessageBox.Show("Redémarrer l'application SVP !");
         Application.Exit();
     }
 }
Exemple #7
0
        private void buttonX10_Click_1(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                String msg = MessageBox.Show("Voulez-Vous Créer Exercice ???", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                if (msg.Equals("Yes"))
                {
                    if (comboBoxEx1.Items.Count != 0)
                    {
                        string  sql1  = "Select Codes,codee From exercice Where codes = '" + xcodes + "' and codee = '" + anne.SelectedItem + "' ";
                        DataSet verif = met.recuperer_table(sql1);

                        if (verif.Tables[0].Rows.Count == 0)
                        {
                            String req1 = "INSERT INTO exercice(codes,codee,libelle) Values ('" + xcodes
                                          + "','" + anne.SelectedItem
                                          + "','" + textBox10.Text
                                          + "')";
                            if (met.Execute(req1))
                            {
                                progressBarX1.Maximum = 8;
                                progressBarX1.Value   = 0;
                                progressBarX1.Visible = true;

                                // Table xxxxx
                                // Table yyyyy

                                MessageBox.Show("Création Exercice Avec Succés");
                            }

                            String req12 = "SELECT * FROM exercice";
                            ds1 = met.recuperer_table(req12, "exercice");

                            String req13 = "SELECT * FROM ste";
                            ds = met.recuperer_table(req13, "ste");
                        }
                        else
                        {
                            MessageBox.Show("Exercice déja Existant");
                        }
                    }
                } // fin message (yes/no)
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #8
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            String msg = MessageBox.Show("Ete-vous sur", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();

            if (msg.Equals("Yes"))
            {
                progressBarX1.Maximum = checkedListBox1.CheckedIndices.Count;
                progressBarX1.Value   = 0;
                progressBarX1.Visible = true;
                foreach (int i in checkedListBox1.CheckedIndices)
                {
                    String table = ds.Tables["Nomtable"].Rows[i].Field <string>("nom");
                    String sql   = "Delete From " + table + " where codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "'";
                    met.Execute(sql);
                    progressBarX1.Value++;
                }
                progressBarX1.Visible = false;
                MessageBox.Show("suppression avec succée");
            }
        }
Exemple #9
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                String req = "Update pnumste Set dfacture = '" + t1.Text
                             + "', facture = '" + t2.Text
                             + "', codeclient = '" + t5.Text
                             + "' Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                if (met.Execute(req))
                {
                    MessageBox.Show("Sauvgarde effectué");
                }

                pnumste_Load(sender, e);
                this.buttonX1.Focus();
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #10
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            //   if (comboBox1.SelectedIndex!=-1 && comboBox1.SelectedIndex!=-1 && t1.Text!="")
            if (comboBox1.SelectedIndex != -1 && comboBox1.SelectedIndex != -1)
            {
                string  sqlcli = "select code from client where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codef = '" + comboBox1.SelectedValue + "'";
                DataSet dscli  = met.recuperer_table(sqlcli, "client");
                if (dscli != null)
                {
                    wnbre = dscli.Tables[0].Rows.Count;

                    foreach (DataRow dr in dscli.Tables["client"].Rows)
                    {
                        string xcodec = dr.Field <string>("code");

                        string  sqlart = "select code from article where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codef = '" + comboBox2.SelectedValue + "'";
                        DataSet dsart  = met.recuperer_table(sqlart, "article");
                        if (dsart != null)
                        {
                            foreach (DataRow dr1 in dsart.Tables["article"].Rows)
                            {
                                string xcodea = dr1.Field <string>("code");


                                //Suppression
                                String req10 = "DELETE FROM tarif where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codec = '" + xcodec + "' and codea = '" + xcodea + "'   ";
                                met.Execute(req10);

                                double xqdeb = 0, xqfin = 0, xremm = 0, xremq = 0;

                                foreach (DataGridViewRow dgr in mygrid3.Rows)
                                {
                                    if (!dgr.IsNewRow)
                                    {
                                        try
                                        {
                                            xqdeb = double.Parse(dgr.Cells["qdeb"].Value + "");
                                        }
                                        catch { }

                                        try
                                        {
                                            xqfin = double.Parse(dgr.Cells["qfin"].Value + "");
                                        }
                                        catch { }

                                        try
                                        {
                                            xremm = double.Parse(dgr.Cells["remisem"].Value + "");
                                        }
                                        catch { }

                                        try
                                        {
                                            xremq = double.Parse(dgr.Cells["remiseq"].Value + "");
                                        }
                                        catch { }


                                        //Sauvegarde
                                        String req = "INSERT INTO tarif(codes,codee,codec,codea,qdeb,qfin,remisem,remiseq,typerem) Values ('" + Program.Societe
                                                     + "','" + Program.Exercice
                                                     + "','" + xcodec
                                                     + "','" + xcodea
                                                     + "', " + xqdeb
                                                     + ", " + xqfin
                                                     + ", " + xremm
                                                     + ", " + xremq
                                                     + ", " + true
                                                     + ")";

                                        met.Execute(req);

                                        xqdeb = 0; xqfin = 0; xremm = 0; xremq = 0;
                                    }
                                }
                            }
                        }
                    }



                    String  req3 = "SELECT codec,codea,qdeb,qfin,remisem,remiseq FROM tarif where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  order by codec,codea,qdeb ";
                    DataSet ds3  = met.recuperer_table(req3, "tarif");
                    label2.Text = ds3.Tables[0].Rows.Count.ToString();
                    if (ds3 != null)
                    {
                        mygrid2.DataSource = ds3.Tables["tarif"].DefaultView;
                    }

                    MessageBox.Show(wnbre + " Clients effectués ");

                    mygrid3.Rows.Clear();
                    comboBox1.SelectedIndex = -1;
                    comboBox2.SelectedIndex = -1;
                }
            }
            else
            {
                MessageBox.Show(" Selectionner Famille Clients,Articles & Saisir Remise ");
            }
        }
Exemple #11
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            // Bouton Sauver
            if (superValidator1.Validate())
            {
                string xsld1 = "Null", xsld = "Null";
                if (!textBoxX1.Text.Trim().Equals(""))
                {
                    xsld1 = "'" + textBoxX1.Text + "'";
                }

                if (!textBoxX4.Text.Trim().Equals(""))
                {
                    xsld = "'" + textBoxX4.Text + "'";
                }

                if (!modif)
                {
                    String  sql   = "SELECT code FROM four  where  codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "' and code ='" + textBox1.Text + "'";
                    DataSet verif = met.recuperer_table(sql);
                    if (verif.Tables[0].Rows.Count == 0)
                    {
                        // Mode création
                        //(Access) string S = "#"+dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day + "/" + dateTimePicker1.Value.Year + "#";
                        //(Mysql) string S =  + dateTimePicker1.Value.Month + "-" + dateTimePicker1.Value.Day + "-" + dateTimePicker1.Value.Year;
                        String req = "INSERT INTO Four(codes,codee,code,codef,libelle,adrl,adrf,adrm,mf,telfixe,telfixe1,telgsm,telgsm1,fax,fax1,timbre,fodecfact,solde1,solde,obs,image) Values ('" + Program.Societe
                                     + "','" + Program.Exercice
                                     + "','" + textBox1.Text
                                     + "','" + comboBox1.SelectedValue
                                     + "','" + textBox2.Text
                                     + "','" + textBox3.Text
                                     + "','" + textBox4.Text
                                     + "','" + textBox5.Text
                                     + "','" + textBox9.Text
                                     + "','" + textBox6.Text
                                     + "','" + textBox10.Text
                                     + "','" + textBox7.Text
                                     + "','" + textBox11.Text
                                     + "','" + textBox8.Text
                                     + "','" + textBox12.Text
                                     + "', " + radioButton3.Checked
                                     + ", " + radioButton1.Checked
                                     + ", " + xsld1.Replace(Program.sep, string.Empty)
                                     + ", " + xsld.Replace(Program.sep, string.Empty)
                                     + ",'" + textBoxX6.Text
                                     + "',@image"
                                     + ")";

                        MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(req, met.mycon);
                        cmd.Parameters.Add("@image", MySql.Data.MySqlClient.MySqlDbType.LongBlob);
                        cmd.Parameters["@image"].Size = Image_stream.Length;
                        if (Image_stream.Length != 0)
                        {
                            cmd.Parameters["@image"].Value = Image_stream;
                        }
                        else
                        {
                            cmd.Parameters["@image"].Value = DBNull.Value;
                        }
                        cmd.ExecuteNonQuery();

                        // Incrémentation code fournisseur
                        String req2 = "SELECT * FROM pnumste where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'";
                        ds = met.recuperer_table(req2, "pnumste");
                        string s2   = ds.Tables[0].Rows[index].Field <Object>("codefour") + "";
                        String snum = textBox1.Text;
                        int    anum = int.Parse(snum);
                        xnum = int.Parse(s2);
                        xnum++;
                        if (anum >= xnum)
                        {
                            string s  = anum.ToString().Trim();
                            int    l1 = s2.Trim().Length;
                            int    l2 = s.Length;
                            for (int ii = l2; ii < l1; ii++)
                            {
                                s = "0" + s;
                            }
                            string sqlinc = "UPDATE pnumste SET codefour = '" + s + "' where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'";
                            met.Execute(sqlinc);
                        }



                        String req7 = "SELECT * FROM four where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' Order by code ";
                        ds = met.recuperer_table(req7, "four");

                        string  req8 = "SELECT MAX(ID) from four ";
                        DataSet ds2  = met.recuperer_table(req8, "four");


                        List <DataColumn> lis = new List <DataColumn>();
                        lis.Add(ds.Tables["four"].Columns["ID"]);
                        ds.Tables["four"].PrimaryKey = lis.ToArray();
                        DataRow[] dr1 = ds.Tables["four"].Select("ID = '" + ds2.Tables[0].Rows[0].ItemArray[0] + "'");
                        if (dr1.Length != 0)
                        {
                            index = ds.Tables[0].Rows.IndexOf(dr1[0]);
                        }

                        MessageBox.Show("Sauvgarde effectué");

                        string req4 = "SELECT * FROM four where codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "' Order by code";
                        ds = met.recuperer_table(req4, "four");

                        affiche();
                        afficheb();
                    }
                    else
                    {
                        MessageBox.Show("Code déja existant");
                    }
                }
                else // Modification
                {
                    // Mode Modification
                    String req = "Update Four Set codes = '" + Program.Societe
                                 + "', codee = '" + Program.Exercice
                                 + "', code = '" + textBox1.Text
                                 + "', libelle = '" + textBox2.Text
                                 + "', adrf = '" + textBox3.Text
                                 + "', adrl = '" + textBox4.Text
                                 + "', adrm='" + textBox5.Text
                                 + "', mf='" + textBox9.Text
                                 + "',telfixe='" + textBox6.Text
                                 + "',telfixe1='" + textBox10.Text
                                 + "',telgsm='" + textBox7.Text
                                 + "',telgsm1='" + textBox11.Text
                                 + "',fax='" + textBox8.Text
                                 + "',fax1='" + textBox12.Text
                                 + "',codef='" + comboBox1.SelectedValue
                                 + "',timbre = " + radioButton3.Checked
                                 + ",fodecfact = " + radioButton1.Checked
                                 + ",solde1=" + xsld1.Replace(Program.sep, string.Empty)
                                 + ",solde=" + xsld.Replace(Program.sep, string.Empty)
                                 + ",obs='" + textBoxX6.Text
                                 + "',image=@image"
                                 + " Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                    MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand(req, met.mycon);
                    cmd.Parameters.Add("@image", MySql.Data.MySqlClient.MySqlDbType.LongBlob);
                    cmd.Parameters["@image"].Size = Image_stream.Length;
                    if (Image_stream.Length != 0)
                    {
                        cmd.Parameters["@image"].Value = Image_stream;
                    }
                    else
                    {
                        cmd.Parameters["@image"].Value = DBNull.Value;
                    }
                    cmd.ExecuteNonQuery();

                    MessageBox.Show("Sauvgarde effectué");


                    modif = false;
                    string req4 = "SELECT * FROM four where codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "' Order by code";
                    ds = met.recuperer_table(req4, "four");
                    affiche();
                    afficheb();
                    this.buttonX6.Focus();
                }
            }
        }
Exemple #12
0
        private void buttonItem3_Click(object sender, EventArgs e)
        {
            if (mygrid1.SelectedRows != null)
            {
                if (mygrid1.SelectedRows.Count != 0)
                {
                    Boolean test = true;
                    if (table == "familleclient")
                    {
                        String  req2 = "SELECT codef FROM client where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codef='" + mytext1.Text + "' ";
                        DataSet ds2  = met.recuperer_table(req2, "client");
                        if (ds2 != null)
                        {
                            if (ds2.Tables["client"].Rows.Count != 0)
                            {
                                test = false;
                            }
                        }
                    }

                    if (table == "famillefour")
                    {
                        String  req2 = "SELECT codef FROM four where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codef='" + mytext1.Text + "' ";
                        DataSet ds2  = met.recuperer_table(req2, "four");
                        if (ds2 != null)
                        {
                            if (ds2.Tables["four"].Rows.Count != 0)
                            {
                                test = false;
                            }
                        }
                    }

                    if (table == "famillearticle")
                    {
                        String  req2 = "SELECT codef FROM article where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codef='" + mytext1.Text + "' ";
                        DataSet ds2  = met.recuperer_table(req2, "article");
                        if (ds2 != null)
                        {
                            if (ds2.Tables["article"].Rows.Count != 0)
                            {
                                test = false;
                            }
                        }
                    }

                    if (table == "region")
                    {
                        String  req2 = "SELECT coder FROM client where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and coder='" + mytext1.Text + "' ";
                        DataSet ds2  = met.recuperer_table(req2, "client");
                        if (ds2 != null)
                        {
                            if (ds2.Tables["client"].Rows.Count != 0)
                            {
                                test = false;
                            }
                        }
                    }

                    if (test)
                    {
                        String msg = MessageBox.Show("Vous êtes Sur de supprimer ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                        if (msg.Equals("Yes"))
                        {
                            String sql = "DELETE FROM " + table + " WHERE ID = " + mygrid1.SelectedRows[0].Cells["c1"].Value;
                            met.Execute(sql);


                            int ind = mygrid1.SelectedRows[0].Index;
                            load_data();
                            if (mygrid1.Rows.Count != 0)
                            {
                                if (ind < mygrid1.Rows.Count)
                                {
                                    mygrid1.CurrentCell        = mygrid1.Rows[ind].Cells[1];
                                    mygrid1.Rows[ind].Selected = true;
                                }
                                else
                                {
                                    ind = mygrid1.Rows.Count - 1;
                                    mygrid1.CurrentCell        = mygrid1.Rows[ind].Cells[1];
                                    mygrid1.Rows[ind].Selected = true;
                                }
                            }

                            dgv_click();
                            buttonX1_Click(sender, e);
                            MessageBox.Show("Suppression avec succée");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Suppression Impossible, " + table + " Utilisée");
                    }
                }
            }
        }
Exemple #13
0
        private void buttonX5_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                string xnfact;

                progressBarX1.Value   = 0;
                progressBarX1.Visible = true;
                foreach (DataGridViewRow dgr in mygrid2.Rows)
                {
                    progressBarX1.Maximum = mygrid2.Rows.Count;

                    if (dgr.Cells["choixp"].Value != null)
                    {
                        if ((Boolean)dgr.Cells["choixp"].Value)
                        {
                            decimal xreg = 0, xttc = 0, xavr = 0, xttc1 = 0, xret = 0, xrem = 0, xsld1 = 0;
                            decimal zmnt = 0, zttc = 0, zavr = 0, zreg = 0, zrem = 0, zret = 0;


                            string xcode = dgr.Cells["codea"].Value + "";


                            ////// Client
                            string req = "Select ID,code,libelle,solde1 from client where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code ='" + xcode + "'  ";
                            ds = met.recuperer_table(req, "client");

                            if (ds.Tables[0].Rows.Count != 0)
                            {
                                try
                                {
                                    xsld1 = ds.Tables[0].Rows[0].Field <decimal>("solde1");
                                }
                                catch { }
                            }

                            string  req1 = "Select Sum(totalttc) as totalttc,Sum(montret1) as retenue,Sum(montrem) as remise from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "' and codec='" + xcode + "' ";
                            DataSet tmp1 = met.recuperer_table(req1, "eentc");

                            try
                            {
                                xttc += tmp1.Tables[0].Rows[0].Field <Decimal>("totalttc");
                                xret += tmp1.Tables[0].Rows[0].Field <Decimal>("retenue");
                                xrem += tmp1.Tables[0].Rows[0].Field <Decimal>("remise");
                            }
                            catch { }



                            string  req2 = "Select Sum(totalttc) as totalttc from eentl where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and codec='" + xcode + "' and facture = false ";
                            DataSet tmp2 = met.recuperer_table(req2, "eentl");

                            try
                            {
                                xttc1 += tmp2.Tables[0].Rows[0].Field <Decimal>("totalttc");
                            }
                            catch { }


                            string  req3 = "Select Sum(totalttc) as totalttc from eentvc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and codec='" + xcode + "'";
                            DataSet tmp3 = met.recuperer_table(req3, "eentvc");

                            try
                            {
                                xavr += tmp3.Tables[0].Rows[0].Field <Decimal>("totalttc");
                            }
                            catch { }


                            string  req4 = "Select Sum(mont) as mont from eregc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "' and codec='" + xcode + "'";
                            DataSet tmp4 = met.recuperer_table(req4, "eregc");

                            try
                            {
                                xreg += tmp4.Tables[0].Rows[0].Field <Decimal>("mont");
                            }
                            catch { }

                            ////// Sauvergarde Client
                            String req5 = "Update Client Set debit = " + (xttc + xttc1)
                                          + ", credit  = " + xreg
                                          + ", avoir   = " + xavr
                                          + ", retenue  = " + xret
                                          + ", rem      = " + xrem
                                          + ", solde    = " + ((xsld1 + xttc + xttc1) - (xavr + xreg + xret + xrem))
                                          + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code='" + xcode + "'";

                            met.Execute(req5);

                            // Retour Montant avoir & montant reglement a 0 pour facture client
                            string  req10 = "Select montavr,montreg from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "' and codec='" + xcode + "'";
                            DataSet tmp10 = met.recuperer_table(req10, "eentc");
                            foreach (DataRow dr3 in tmp10.Tables["eentc"].Rows)
                            {
                                String req6 = "Update eentc Set MONTAVR = " + zmnt
                                              + ", montreg = " + zmnt
                                              + ", montrem = " + zmnt
                                              + ", montret1 = " + zmnt
                                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + xcode + "'";
                                met.Execute(req6);
                            }

                            // calcul Montant avoir  pour facture client

                            string  req11 = "Select totalttc,nfact from eentvc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and codec='" + xcode + "'";
                            DataSet tmp11 = met.recuperer_table(req11, "eentvc");
                            foreach (DataRow dr3 in tmp11.Tables["eentvc"].Rows)
                            {
                                xnfact = dr3.Field <string>("nfact");
                                try
                                {
                                    zmnt = dr3.Field <Decimal>("totalttc");
                                }
                                catch { }

                                String req7 = "Update eentc Set MONTAVR = " + zmnt
                                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and num ='" + xnfact + "'";
                                met.Execute(req7);
                            }

                            // calcul Montant reglement  pour facture client
                            string  req17 = "Select num from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'   and codec='" + xcode + "'";
                            DataSet tmp17 = met.recuperer_table(req17, "eentc");
                            decimal wzmnt = 0, wrem = 0, wret = 0;
                            foreach (DataRow dr3 in tmp17.Tables["eentc"].Rows)
                            {
                                xnfact = dr3.Field <string>("num");

                                string  req7 = "Select mont,mntrem,mntret,nfact from lregc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and nfact ='" + xnfact + "'";
                                DataSet tmp7 = met.recuperer_table(req7, "lregc");

                                foreach (DataRow dr2 in tmp7.Tables["lregc"].Rows)
                                {
                                    try
                                    {
                                        wzmnt += dr2.Field <Decimal>("mont");
                                    }
                                    catch { }

                                    try
                                    {
                                        wrem += dr2.Field <Decimal>("mntrem");
                                    }
                                    catch { }

                                    try
                                    {
                                        wret += dr2.Field <Decimal>("mntret");
                                    }
                                    catch { }
                                }

                                String req8 = "Update eentc Set MONTREG = " + wzmnt
                                              + ", montrem = " + wrem
                                              + ", montret1 = " + wret
                                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num ='" + xnfact + "'";
                                met.Execute(req8);
                                wzmnt = wrem = wret = 0;
                            }

                            //calcul  solde facture client
                            string  req12 = "Select num,totalttc,montavr,montreg,montrem,montret1,reste from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'   and codec='" + xcode + "'";
                            DataSet tmp12 = met.recuperer_table(req12, "eentc");
                            foreach (DataRow dr3 in tmp12.Tables["eentc"].Rows)
                            {
                                xnfact = dr3.Field <string>("num");
                                try
                                {
                                    zttc = dr3.Field <Decimal>("totalttc");
                                }
                                catch { }

                                try
                                {
                                    zavr = dr3.Field <Decimal>("montavr");
                                }
                                catch { }

                                try
                                {
                                    zreg = dr3.Field <Decimal>("montreg");
                                }
                                catch { }

                                try
                                {
                                    zrem = dr3.Field <Decimal>("montrem");
                                }
                                catch { }

                                try
                                {
                                    zret = dr3.Field <Decimal>("montret1");
                                }
                                catch { }

                                String req9 = "Update eentc Set reste = " + ((zttc - (zavr + zreg + zrem + zret)))
                                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'  and num ='" + xnfact + "'";
                                met.Execute(req9);
                            }



                            progressBarX1.Value++;
                        }
                    }
                }

                progressBarX1.Visible = false;
                MessageBox.Show("Réorganisation  effectuée avec Succés");
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #14
0
        private void buttonX3_Click(object sender, EventArgs e)
        {
            // Bouton Supprimer Facture
            if (dataGridViewX1.Rows.Count != 0)
            {
                if (dataGridViewX1.SelectedRows[0].Cells["mode"].Value + "" == "D")
                {
                    string  sql = "select * from eentc where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codem='" + Program.Magasin + "' and  num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "' and regle = false";
                    DataSet dss = met.recuperer_table(sql, "eentc");
                    if (dss.Tables["eentc"].Rows.Count != 0)
                    {
                        String msg = MessageBox.Show("Ete-vous sur", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                        if (msg.Equals("Yes"))
                        {
                            string  req1 = "Select * from lentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codem='" + Program.Magasin + "'  and  num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "' ";
                            DataSet tmp1 = met.recuperer_table(req1, "lentc");
                            foreach (DataRow dr1 in tmp1.Tables["lentc"].Rows)
                            {
                                double xqte = 0, QTESTK = 0, QTESOR = 0, QTEMAG = 0, QTESORMAG = 0, QTESTE = 0, QTESORSTE = 0;
                                string xcodea = "";
                                xcodea = dr1.Field <string>("codea" + "");
                                string xcodeg = dr1.Field <string>("codeg" + "");
                                string xcoded = dr1.Field <string>("coded" + "");

                                xqte = dr1.Field <double>("qte");
                                try
                                {
                                    xqte = dr1.Field <double>("qte");
                                }
                                catch { }

                                #region // Update stock
                                string  sql1 = "Select qtestk,qtesor from artdep where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codea ='" + xcodea + "' and coded='" + xcoded + "' and codem='" + Program.Magasin + "' and codeg='" + xcodeg + "'";
                                DataSet ds1  = met.recuperer_table(sql1, "artdep");
                                if (ds1 != null)
                                {
                                    if (ds1.Tables.Count != 0)
                                    {
                                        if (ds1.Tables["artdep"].Rows.Count != 0)
                                        {
                                            Double.TryParse(ds1.Tables["artdep"].Rows[0]["qtestk"] + "", out QTESTK);
                                            Double.TryParse(ds1.Tables["artdep"].Rows[0]["qtesor"] + "", out QTESOR);
                                        }
                                    }
                                }

                                string  sql2 = "Select qtestk,qtesor from artmag where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codea ='" + xcodea + "'  and codem='" + Program.Magasin + "'";
                                DataSet ds2  = met.recuperer_table(sql2, "artmag");
                                if (ds2 != null)
                                {
                                    if (ds2.Tables.Count != 0)
                                    {
                                        if (ds2.Tables["artmag"].Rows.Count != 0)
                                        {
                                            Double.TryParse(ds2.Tables["artmag"].Rows[0]["qtestk"] + "", out QTEMAG);
                                            Double.TryParse(ds2.Tables["artmag"].Rows[0]["qtesor"] + "", out QTESORMAG);
                                        }
                                    }
                                }

                                string  sql3 = "Select qtestk,qtesor,vstk from article where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and code ='" + xcodea + "' ";
                                DataSet ds3  = met.recuperer_table(sql3, "article");
                                if (ds3 != null)
                                {
                                    if (ds3.Tables.Count != 0)
                                    {
                                        if (ds3.Tables["article"].Rows.Count != 0)
                                        {
                                            xvstk = ds3.Tables["article"].Rows[0].Field <Boolean>("vstk");
                                            Double.TryParse(ds3.Tables["article"].Rows[0]["qtestk"] + "", out QTESTE);
                                            Double.TryParse(ds3.Tables["article"].Rows[0]["qtesor"] + "", out QTESORSTE);
                                        }
                                    }
                                }



                                if (xvstk == true)
                                {
                                    string sqlup = "UPDATE artdep set qtestk = '" + (QTESTK + xqte) + "',qtesor='" + (QTESOR - xqte) + "' where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codea ='" + xcodea + "' and coded='" + xcoded + "' and codem='" + Program.Magasin + "' and codeg='" + xcodeg + "'";
                                    met.Execute(sqlup);

                                    sqlup = "UPDATE artmag set qtestk = '" + (QTEMAG + xqte) + "',qtesor='" + (QTESORMAG - xqte) + "' where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codea ='" + xcodea + "'  and codem='" + Program.Magasin + "'";
                                    met.Execute(sqlup);

                                    sqlup = "UPDATE article set qtestk = '" + (QTESTE + xqte) + "',qtesor='" + (QTESORSTE - xqte) + "' where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and code ='" + xcodea + "' ";
                                    met.Execute(sqlup);
                                }
                                #endregion // Update stock
                            }


                            String  req5 = "Select code,debit,solde From client where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND Code = '" + dataGridViewX1.SelectedRows[0].Cells["codec"].Value + "'";
                            DataSet dsc = met.recuperer_table(req5, "client");
                            decimal wdeb = 0, wsld = 0;
                            try
                            {
                                wdeb = dsc.Tables["client"].Rows[0].Field <decimal>("debit");
                            }
                            catch { }

                            try
                            {
                                wsld = dsc.Tables["client"].Rows[0].Field <decimal>("solde");
                            }
                            catch { }

                            try
                            {
                                decimal.TryParse(dataGridViewX1.SelectedRows[0].Cells["TOTALTTC"].Value + "", out xdeb);
                            }
                            catch { }

                            String upcli = "UPDATE client SET debit = " + (wdeb - xdeb)
                                           + ", solde=" + (wsld - xdeb)
                                           + " where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND Code = '" + dataGridViewX1.SelectedRows[0].Cells["codec"].Value + "'";
                            met.Execute(upcli);


                            String  req6 = "Select code,vente,taux,com From rep where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND Code = '" + dataGridViewX1.SelectedRows[0].Cells["coder"].Value + "'";
                            DataSet dsr = met.recuperer_table(req6, "rep");
                            decimal wven = 0, nven = 0;
                            double  wcom = 0, wtaux = 0;
                            try
                            {
                                wven = dsr.Tables["rep"].Rows[0].Field <decimal>("vente");
                            }
                            catch { }
                            try
                            {
                                wtaux = dsr.Tables["rep"].Rows[0].Field <double>("taux");
                            }
                            catch { }

                            try
                            {
                                decimal.TryParse(dataGridViewX1.SelectedRows[0].Cells["TOTALHT"].Value + "", out xven);
                            }
                            catch { }

                            nven = wven - xven;
                            wcom = (double)nven * (wtaux / 100);
                            String uprep = "UPDATE rep SET vente = " + nven
                                           + ", com=" + wcom
                                           + " where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND Code = '" + dataGridViewX1.SelectedRows[0].Cells["coder"].Value + "'";
                            met.Execute(uprep);



                            String req3 = "DELETE FROM eentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";

                            if (met.Execute(req3))
                            {
                                String req4 = "DELETE FROM lentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                                if (met.Execute(req4))
                                {
                                    MessageBox.Show("Suppression effectuée");
                                }
                            }
                            buttonX1_Click(sender, e);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Facture Reglée");
                    }
                }
                else if (dataGridViewX1.SelectedRows[0].Cells["mode"].Value + "" == "L")
                {
                    string  sql = "select * from eentc where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codem='" + Program.Magasin + "' and  num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "' and regle = false";
                    DataSet dss = met.recuperer_table(sql, "eentc");
                    if (dss.Tables["eentc"].Rows.Count != 0)
                    {
                        String msg = MessageBox.Show("Ete-vous sur", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                        if (msg.Equals("Yes"))
                        {
                            string  sqln = "select * from nblfacture where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codem='" + Program.Magasin + "' and  numf = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            DataSet dsn  = met.recuperer_table(sqln, "nblfacture");
                            if (dsn != null)
                            {
                                foreach (DataRow dr in dsn.Tables["nblfacture"].Rows)
                                {
                                    string xnbl = dr.Field <string>("numl");

                                    String upbl = "UPDATE eentl SET facture = " + false
                                                  + " where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND codem ='" + Program.Magasin + "' AND num = '" + xnbl + "'";
                                    met.Execute(upbl);
                                }
                            }

                            String req3 = "DELETE FROM eentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req3);
                            String req4 = "DELETE FROM lentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req4);
                            String req5 = "DELETE FROM nblfacture Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and numf = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req5);
                            MessageBox.Show("Suppression effectuée");
                            buttonX1_Click(sender, e);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Facture Reglée");
                    }
                }
                else if (dataGridViewX1.SelectedRows[0].Cells["mode"].Value + "" == "B")
                {
                    string  sql = "select * from eentc where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codem='" + Program.Magasin + "' and  num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                    DataSet dss = met.recuperer_table(sql, "eentc");
                    if (dss.Tables["eentc"].Rows.Count != 0)
                    {
                        String msg = MessageBox.Show("Ete-vous sur", "Important", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
                        if (msg.Equals("Yes"))
                        {
                            string  sqln = "select * from nblfacture where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and codem='" + Program.Magasin + "' and  numf = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            DataSet dsn  = met.recuperer_table(sqln, "nblfacture");
                            if (dsn != null)
                            {
                                foreach (DataRow dr in dsn.Tables["nblfacture"].Rows)
                                {
                                    string xnbl = dr.Field <string>("numl");

                                    String upbl = "UPDATE eentcb SET facture = " + false
                                                  + " where codes = '" + Program.Societe + "' AND codee ='" + Program.Exercice + "' AND codem ='" + Program.Magasin + "' AND num = '" + xnbl + "'";
                                    met.Execute(upbl);
                                }
                            }

                            String req3 = "DELETE FROM eentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req3);
                            String req4 = "DELETE FROM lentc Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and num = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req4);
                            String req5 = "DELETE FROM nblfacture Where codes = '" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and numf = '" + dataGridViewX1.SelectedRows[0].Cells["num"].Value + "'";
                            met.Execute(req5);
                            MessageBox.Show("Suppression effectuée");
                            buttonX1_Click(sender, e);
                        }
                    }
                }
            }
        }
Exemple #15
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            if (!Log.Text.Equals("") && !PWD.Text.Equals("") && Soc.SelectedIndex != -1 && Exerc.SelectedIndex != -1)
            {
                DataSet ds = met.recuperer_table("Select * From utilisateur Where libelle = '" + Log.Text + "' AND mp = '" + PWD.Text + "'", "utilisateur");
                if (ds.Tables["utilisateur"].Rows.Count != 0)
                {
                    Program.Societe  = Soc.SelectedValue.ToString();
                    Program.Exercice = ((DataRowView)Exerc.SelectedValue).Row.ItemArray[2] + "";
                    Program.User     = ds.Tables["utilisateur"].Rows[0].Field <String>("code");
                    Program.LibUser  = ds.Tables["utilisateur"].Rows[0].Field <String>("libelle");
                    if (ds.Tables["utilisateur"].Rows[0].Field <String>("type").Equals("S"))
                    {
                        Program.ISSaDmin = true;
                        Program.ISaDmin  = true;
                        Program.TypUser  = "******";
                    }
                    if (ds.Tables["utilisateur"].Rows[0].Field <String>("type").Equals("A"))
                    {
                        Program.ISaDmin = true;
                        Program.TypUser = "******";
                    }
                    if (ds.Tables["utilisateur"].Rows[0].Field <String>("type").Equals("U"))
                    {
                        Program.TypUser = "******";
                    }
                    /// Controle programme

                    String  req = "SELECT * FROM propos";
                    DataSet ds2 = met.recuperer_table(req, "propos");
                    if (ds2 != null)
                    {
                        if (ds2.Tables.Count != 0)
                        {
                            if (ds2.Tables[0].Rows.Count != 0)
                            {
                                wdateprog = ds2.Tables[0].Rows[0].Field <DateTime>("imaged");
                            }
                        }
                    }

                    int wpasse = 850120156;
                    if (wdateprog < wdatejours)
                    {
                        String req1 = "Update propos Set imagef = " + wpasse + " ";
                        met.Execute(req1);
                    }


                    //String reqsp = "select * FROM propos ";
                    //DataSet dsprp = met.recuperer_table(reqsp, "propos");
                    //if (dsprp != null)
                    //{
                    //    if (dsprp.Tables.Count != 0)
                    //    {
                    //        wdateprog = dsprp.Tables[0].Rows[0].Field<DateTime>("imaged");
                    //        wpasseprog = dsprp.Tables[0].Rows[0].Field<int>("imagef");
                    //    }
                    //}


                    //if (wdateprog < wdatejours || wpasseprog != 21011966)
                    //{
                    //    Program.ISAret = true;
                    //    Program.ISDemo = true;
                    //}

                    ///

                    this.Hide();
                    Menugen1 mg = new Menugen1();
                    mg.Show();
                }
                else
                {
                    MessageBox.Show("Verifier Votre Login et/ou Mot de passe");
                }
            }
            else
            {
                MessageBox.Show("Veillez Remplir Tous les champs");
            }
        }
Exemple #16
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            progressBarX1.Value   = 0;
            progressBarX1.Visible = true;
            string  xnfact;
            decimal zmnt = 0, zttc = 0, zavr = 0, zreg = 0;

            string req = "Select ID,code,libelle,solde1 from client where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' order by code ";

            ds = met.recuperer_table(req, "client");
            progressBarX1.Maximum = (ds.Tables["client"].Rows.Count) / 3;
            foreach (DataRow dr in ds.Tables["client"].Rows)
            {
                decimal xreg = 0, xttc = 0, xavr = 0, xttc1 = 0, xsld1 = 0;

                textBoxX1.Text = dr.Field <string>("code");
                textBoxX2.Text = dr.Field <string>("libelle");
                label1.Text    = "Client";
                this.Update();

                try
                {
                    xsld1 = dr.Field <Decimal>("solde1");
                }
                catch { }



                string  req1 = "Select Sum(totalttc) as totalttc from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "' ";
                DataSet tmp1 = met.recuperer_table(req1, "eentc");

                try
                {
                    xttc += tmp1.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }



                string  req2 = "Select Sum(totalttc) as totalttc from eentl where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "' and facture = false ";
                DataSet tmp2 = met.recuperer_table(req2, "eentl");

                try
                {
                    xttc1 += tmp2.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }


                string  req3 = "Select Sum(totalttc) as totalttc from eentvc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "'";
                DataSet tmp3 = met.recuperer_table(req3, "eentvc");

                try
                {
                    xavr += tmp3.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }


                string  req4 = "Select Sum(mont) as mont from eregc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "'";
                DataSet tmp4 = met.recuperer_table(req4, "eregc");

                try
                {
                    xreg += tmp4.Tables[0].Rows[0].Field <Decimal>("mont");
                }
                catch { }


                String req5 = "Update Client Set debit = " + (xttc + xttc1)
                              + ", credit = " + xreg
                              + ", avoir   = " + xavr
                              + ", solde   = " + ((xsld1 + xttc + xttc1) - (xavr + xreg))
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code='" + textBoxX1.Text + "'";

                met.Execute(req5);

                progressBarX1.Value++;
            }

            string reqr = "Select ID,code,libelle,taux from rep where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' order by code ";

            ds = met.recuperer_table(reqr, "rep");
            progressBarX1.Maximum = (ds.Tables["rep"].Rows.Count) / 3;
            foreach (DataRow dr in ds.Tables["rep"].Rows)
            {
                decimal xven = 0, xven1 = 0;
                double  xtaux = 0, xcom = 0;

                textBoxX1.Text = dr.Field <string>("code");
                textBoxX2.Text = dr.Field <string>("libelle");
                label1.Text    = "Représentant";
                this.Update();

                try
                {
                    xtaux = dr.Field <double>("taux");
                }
                catch { }



                string  req1 = "Select Sum(totalht) as totalht from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and coder='" + textBoxX1.Text + "' ";
                DataSet tmp1 = met.recuperer_table(req1, "eentc");

                try
                {
                    xven += tmp1.Tables[0].Rows[0].Field <Decimal>("totalht");
                }
                catch { }


                string  req2 = "Select Sum(totalht) as totalht from eentl where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and coder='" + textBoxX1.Text + "' and facture = false ";
                DataSet tmp2 = met.recuperer_table(req2, "eentl");

                try
                {
                    xven1 += tmp2.Tables[0].Rows[0].Field <Decimal>("totalht");
                }
                catch { }



                xcom = (double)(xven + xven1) * (xtaux / 100);
                String req5 = "Update rep Set vente = " + (xven + xven1)
                              + ", com = " + xcom
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code='" + textBoxX1.Text + "'";

                met.Execute(req5);

                progressBarX1.Value++;
            }


            string reqf = "Select ID,code,libelle,solde1 from four where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' order by code ";

            ds = met.recuperer_table(reqf, "four");
            progressBarX1.Maximum += (ds.Tables["four"].Rows.Count) / 3;
            foreach (DataRow dr in ds.Tables["four"].Rows)
            {
                decimal wreg = 0, wttc = 0, wavr = 0, wttc1 = 0, wsld1 = 0;

                textBoxX1.Text = dr.Field <string>("code");
                textBoxX2.Text = dr.Field <string>("libelle");
                label1.Text    = "Fournisseur";
                this.Update();

                try
                {
                    wsld1 = dr.Field <Decimal>("solde1");
                }
                catch { }



                string  req1 = "Select Sum(totalttc) as totalttc from eentf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "' ";
                DataSet tmp1 = met.recuperer_table(req1, "eentf");

                try
                {
                    wttc += tmp1.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }



                string  req2 = "Select Sum(totalttc) as totalttc from eente where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "' and facture = false ";
                DataSet tmp2 = met.recuperer_table(req2, "eente");

                try
                {
                    wttc1 += tmp2.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }



                string  req3 = "Select Sum(totalttc) as totalttc from eentvf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "'";
                DataSet tmp3 = met.recuperer_table(req3, "eentvf");

                try
                {
                    wavr += tmp3.Tables[0].Rows[0].Field <Decimal>("totalttc");
                }
                catch { }


                string  req4 = "Select Sum(mont) as mont from eregf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and codec='" + textBoxX1.Text + "'";
                DataSet tmp4 = met.recuperer_table(req4, "eregf");

                try
                {
                    wreg += tmp4.Tables[0].Rows[0].Field <Decimal>("mont");
                }
                catch { }



                String req5 = "Update four Set debit = " + (wttc + wttc1)
                              + ", credit = " + wreg
                              + ", avoir   = " + wavr
                              + ", solde   = " + ((wsld1 + wttc + wttc1) - (wavr + wreg))
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and code='" + textBoxX1.Text + "'";

                met.Execute(req5);


                progressBarX1.Value++;
            }

            // Retour Montant avoir & montant reglement a 0 pour facture client
            string  req10 = "Select montavr,montreg from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp10 = met.recuperer_table(req10, "eentc");

            foreach (DataRow dr3 in tmp10.Tables["eentc"].Rows)
            {
                String req5 = "Update eentc Set MONTAVR = " + zmnt
                              + ", montreg = " + zmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
                met.Execute(req5);
            }

            // Retour Montant avoir & montant reglement a 0 pour facture fournisseur
            string  req11 = "Select montavr,montreg from eentf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp11 = met.recuperer_table(req11, "eentf");

            foreach (DataRow dr3 in tmp11.Tables["eentf"].Rows)
            {
                String req5 = "Update eentf Set MONTAVR = " + zmnt
                              + ", montreg = " + zmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
                met.Execute(req5);
            }

            // calcul Montant avoir  pour facture client
            string  req6 = "Select totalttc,nfact from eentvc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp6 = met.recuperer_table(req6, "eentvc");

            foreach (DataRow dr3 in tmp6.Tables["eentvc"].Rows)
            {
                xnfact = dr3.Field <string>("nfact");
                try
                {
                    zmnt = dr3.Field <Decimal>("totalttc");
                }
                catch { }

                String req5 = "Update eentc Set MONTAVR = " + zmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and num ='" + xnfact + "'";
                met.Execute(req5);
            }
            // calcul Montant reglement  pour facture client
            string  req17 = "Select num from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp17 = met.recuperer_table(req17, "eentc");
            decimal wzmnt = 0;

            foreach (DataRow dr3 in tmp17.Tables["eentc"].Rows)
            {
                xnfact = dr3.Field <string>("num");

                string  req7 = "Select mont,nfact from lregc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and nfact ='" + xnfact + "'";
                DataSet tmp7 = met.recuperer_table(req7, "lregc");

                foreach (DataRow dr2 in tmp7.Tables["lregc"].Rows)
                {
                    try
                    {
                        wzmnt += dr2.Field <Decimal>("mont");
                    }
                    catch { }
                }

                String req5 = "Update eentc Set MONTREG = " + wzmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and num ='" + xnfact + "'";
                met.Execute(req5);
                wzmnt = 0;
            }
            // calcul Montant avoir  pour facture fournisseur
            string  req8 = "Select totalttc,nfact from eentvf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp8 = met.recuperer_table(req8, "eentvf");

            foreach (DataRow dr3 in tmp8.Tables["eentvf"].Rows)
            {
                xnfact = dr3.Field <string>("nfact");
                try
                {
                    zmnt = dr3.Field <Decimal>("totalttc");
                }
                catch { }

                String req5 = "Update eentf Set MONTAVR = " + zmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and num ='" + xnfact + "'";
                met.Execute(req5);
            }
            // calcul Montant reglement  pour facture fournisseur
            string  req19 = "Select num from eentf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp19 = met.recuperer_table(req19, "eentf");
            decimal zzmnt = 0;

            foreach (DataRow dr3 in tmp19.Tables["eentf"].Rows)
            {
                xnfact = dr3.Field <string>("num");

                string  req7 = "Select mont,nfact from lregf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and nfact ='" + xnfact + "'";
                DataSet tmp7 = met.recuperer_table(req7, "lregf");

                foreach (DataRow dr2 in tmp7.Tables["lregf"].Rows)
                {
                    try
                    {
                        zzmnt += dr2.Field <Decimal>("mont");
                    }
                    catch { }
                }

                String req5 = "Update eentf Set MONTREG = " + zzmnt
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "' and num ='" + xnfact + "'";
                met.Execute(req5);
                zzmnt = 0;
            }

            //calcul  solde facture client
            string  req12 = "Select num,totalttc,montavr,montreg,reste from eentc where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp12 = met.recuperer_table(req12, "eentc");

            foreach (DataRow dr3 in tmp12.Tables["eentc"].Rows)
            {
                xnfact = dr3.Field <string>("num");
                try
                {
                    zttc = dr3.Field <Decimal>("totalttc");
                }
                catch { }

                try
                {
                    zavr = dr3.Field <Decimal>("montavr");
                }
                catch { }

                try
                {
                    zreg = dr3.Field <Decimal>("montreg");
                }
                catch { }

                String req5 = "Update eentc Set reste = " + ((zttc - (zavr + zreg)))
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'  and num ='" + xnfact + "'";
                met.Execute(req5);
            }



            //calcul  solde facture fournisseur
            string  req13 = "Select num,totalttc,montavr,montreg,reste from eentf where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'";
            DataSet tmp13 = met.recuperer_table(req13, "eentf");

            foreach (DataRow dr3 in tmp13.Tables["eentf"].Rows)
            {
                xnfact = dr3.Field <string>("num");
                try
                {
                    zttc = dr3.Field <Decimal>("totalttc");
                }
                catch { }

                try
                {
                    zavr = dr3.Field <Decimal>("montavr");
                }
                catch { }

                try
                {
                    zreg = dr3.Field <Decimal>("montreg");
                }
                catch { }

                String req5 = "Update eentf Set reste = " + ((zttc - (zavr + zreg)))
                              + " Where codes='" + Program.Societe + "' and codee='" + Program.Exercice + "'  and num ='" + xnfact + "'";
                met.Execute(req5);
            }


            MessageBox.Show("Organisation effectuée");
            progressBarX1.Visible = false;
            textBoxX1.Text        = "";
            textBoxX2.Text        = "";
            label1.Text           = "";
        }
Exemple #17
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            Boolean test = true;

            // Bouton Sauver
            if (superValidator1.Validate())
            {
                String  sql   = "SELECT code FROM " + table + " where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'  and code='" + textBox1.Text + "'";
                DataSet verif = met.recuperer_table(sql, table);
                if (verif.Tables[0].Rows.Count != 0)
                {
                    test = false;
                }


                if (!modif)
                {
                    if (test)
                    {
                        String req = "INSERT INTO " + table + "(codes,codee,code,libelle) Values ('" + Program.Societe + "','" + Program.Exercice + "','" + textBox1.Text + "', '" + textBox2.Text + "')";
                        met.Execute(req);

                        //
                        String req2 = "SELECT * FROM pnumste where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'";
                        ds = met.recuperer_table(req2, "pnumste");
                        string s2   = ds.Tables[0].Rows[index].Field <Object>(champs) + "";
                        String snum = textBox1.Text;
                        int    anum = int.Parse(snum);
                        xnum = int.Parse(s2);
                        xnum++;
                        if (anum >= xnum)
                        {
                            string s  = anum.ToString().Trim();
                            int    l1 = s2.Trim().Length;
                            int    l2 = s.Length;
                            for (int ii = l2; ii < l1; ii++)
                            {
                                s = "0" + s;
                            }
                            string sqlinc = "UPDATE pnumste SET " + champs + " = '" + s + "' where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "'";
                            met.Execute(sqlinc);
                        }
                        //

                        MessageBox.Show("Sauvegarde éffectué");

                        String req1 = "SELECT * FROM " + table + " where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and type = '" + xtype + "'  Order by code ";
                        ds = met.recuperer_table(req1, table);

                        string  req5 = "SELECT MAX(ID) from " + table + " ";
                        DataSet ds2  = met.recuperer_table(req5, table);


                        List <DataColumn> lis = new List <DataColumn>();
                        lis.Add(ds.Tables[table].Columns["ID"]);
                        ds.Tables[table].PrimaryKey = lis.ToArray();
                        DataRow[] dr = ds.Tables[table].Select("ID = '" + ds2.Tables[0].Rows[0].ItemArray[0] + "'");
                        if (dr.Length != 0)
                        {
                            index = ds.Tables[0].Rows.IndexOf(dr[0]);
                        }

                        test = true;

                        afficheb();
                        affiche();
                    }
                    else
                    {
                        MessageBox.Show("Code déja existant");
                        test = true;
                    }
                }
                else
                {
                    {
                        // Mode Modification
                        String req = "Update " + table + " Set codes='" + Program.Societe + "',codee='" + Program.Exercice + "',code = '" + textBox1.Text + "', libelle = '" + textBox2.Text + "' Where ID = " + ds.Tables[0].Rows[index].ItemArray[0];

                        if (met.Execute(req))
                        {
                            MessageBox.Show("Sauvegarde éffectué");
                        }

                        modif = false;

                        String req1 = "SELECT * FROM " + table + " where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and type = '" + xtype + "' Order by code ";
                        ds   = met.recuperer_table(req1, table);
                        test = true;
                        afficheb();
                        affiche();
                        this.buttonX6.Focus();
                    }
                }
            }
        }
Exemple #18
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                foreach (DataRow dr in ds.Tables["parametre"].Rows)
                {
                    string xparam = dr.Field <string>("param");

                    String req = "";
                    if (xparam.Equals("TauxMajoration"))
                    {
                        req = "Update parametre Set value = '" + t1.Text
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("Timbre"))
                    {
                        req = "Update parametre Set value = '" + t2.Text
                              + "' Where codes='" + Program.Societe + "'  and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("Cumulqteclient"))
                    {
                        req = "Update parametre Set value = '" + c1.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("Cumulqtefour"))
                    {
                        req = "Update parametre Set value = '" + c2.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("CumulRemiseClient"))
                    {
                        req = "Update parametre Set value = '" + c3.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("BonTicket"))
                    {
                        req = "Update parametre Set value = '" + c4.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RCB"))
                    {
                        req = "Update parametre Set value = '" + c5.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RCL"))
                    {
                        req = "Update parametre Set value = '" + c6.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RCF"))
                    {
                        req = "Update parametre Set value = '" + c7.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RCA"))
                    {
                        req = "Update parametre Set value = '" + c8.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RCR"))
                    {
                        req = "Update parametre Set value = '" + c9.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RFL"))
                    {
                        req = "Update parametre Set value = '" + c10.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RFF"))
                    {
                        req = "Update parametre Set value = '" + c11.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RFA"))
                    {
                        req = "Update parametre Set value = '" + c12.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }
                    else if (xparam.Equals("RFR"))
                    {
                        req = "Update parametre Set value = '" + c13.SelectedItem
                              + "' Where codes='" + Program.Societe + "' and param = '" + xparam + "' ";
                    }


                    met.Execute(req);
                }

                MessageBox.Show("Sauvegarde effectué");

                param_Load(sender, e);
                this.buttonX1.Focus();
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #19
0
        private void buttonX5_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                progressBarX1.Value   = 0;
                progressBarX1.Visible = true;
                foreach (DataGridViewRow dgr in mygrid2.Rows)
                {
                    progressBarX1.Maximum = mygrid2.Rows.Count;

                    if (dgr.Cells["choixp"].Value != null)
                    {
                        if ((Boolean)dgr.Cells["choixp"].Value)
                        {
                            double xqtedep = 0, xstk = 0;
                            Double xtqte = 0, xtqte1 = 0;
                            Double xtqte2 = 0, xtqte3 = 0;
                            Double wtqte = 0, wtqte1 = 0;
                            double wtqte2 = 0, wtqte3 = 0, wstk = 0, wqtedep = 0;
                            string req1 = "";

                            string xcode = dgr.Cells["codea"].Value + "";



                            ////// Article Dépot


                            string reqd = "";
                            reqd = "SELECT code FROM depot  where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' ";
                            DataSet dsd = met.recuperer_table(reqd, "depot");
                            foreach (DataRow drp in dsd.Tables["depot"].Rows)
                            {
                                string wcoded = drp.Field <string>("code");



                                string reqg = "";
                                reqg = "SELECT codeg,libelle FROM gamme  where codea ='" + xcode + "' and codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' ";
                                DataSet dsg = met.recuperer_table(reqg, "gamme");

                                foreach (DataRow drg in dsg.Tables["gamme"].Rows)
                                {
                                    xtqte  = xtqte1 = 0;
                                    xtqte2 = xtqte3 = xstk = xqtedep = 0;

                                    string wcodeg = drg.Field <string>("codeg");

                                    req1 = "SELECT qtedep FROM artdep WHERE codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "' and codem = '" + Program.Magasin + "' and codea ='" + xcode + "' and coded = '" + wcoded + "' and codeg = '" + wcodeg + "' ";
                                    ds   = met.recuperer_table(req1, "artdep");

                                    if (ds.Tables[0].Rows.Count != 0)
                                    {
                                        try
                                        {
                                            xqtedep = ds.Tables[0].Rows[0].Field <double>("qtedep");
                                        }
                                        catch { xqtedep = 0; }

                                        try
                                        {
                                            wqtedep += ds.Tables[0].Rows[0].Field <double>("qtedep");
                                        }
                                        catch {}
                                    }


                                    //req1 = "SELECT  coded,codeg,num,codea,qte,ID  FROM lentf  where coded ='" + wcoded + "' and codeg = '" + wcodeg + "'  and  codea = '" + xcode + "' and codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "'  ";
                                    req1 = "SELECT distinct l.coded,l.codeg,l.num,l.codea,l.qte,e.type,l.ID  FROM lentf l, eentf e  where l.coded ='" + wcoded + "' and l.codeg = '" + wcodeg + "'  and  l.codea = '" + xcode + "' and e.num=l.num and e.type='C' and l.codes='" + Program.Societe + "' and l.codee = '" + Program.Exercice + "' and l.codem='" + Program.Magasin + "' ";
                                    ds   = met.recuperer_table(req1, "lentf");



                                    foreach (DataRow dr in ds.Tables["lentf"].Rows)
                                    {
                                        try
                                        {
                                            xtqte2 += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte2 += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }

                                    req1 = "SELECT distinct l.coded,l.codeg,l.num,l.codea,l.qte,l.ID  FROM lente l, eente e  where l.coded ='" + wcoded + "' and l.codeg = '" + wcodeg + "'  and  l.codea = '" + xcode + "' and l.codes='" + Program.Societe + "' and l.codee = '" + Program.Exercice + "' and l.codem='" + Program.Magasin + "' ";
                                    ds   = met.recuperer_table(req1, "lente");

                                    foreach (DataRow dr in ds.Tables["lente"].Rows)
                                    {
                                        try
                                        {
                                            xtqte2 += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte2 += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    req1 = "SELECT distinct l.coded,l.codeg,l.num,l.codea,l.qte,l.ID  FROM lentcb l, eentcb e  where l.coded ='" + wcoded + "' and l.codeg = '" + wcodeg + "'  and  l.codea = '" + xcode + "' and l.codes='" + Program.Societe + "' and l.codee = '" + Program.Exercice + "' and l.codem='" + Program.Magasin + "' ";
                                    ds   = met.recuperer_table(req1, "lentcb");

                                    foreach (DataRow dr in ds.Tables["lentcb"].Rows)
                                    {
                                        try
                                        {
                                            xtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    //req1 = "SELECT  coded,codeg,num,codea,qte,ID  FROM lentc  where coded ='" + wcoded + "' and codeg = '" + wcodeg + "'  and  codea = '" + xcode + "' and codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "'  ";
                                    req1 = "SELECT distinct l.coded,l.codeg,l.num,l.codea,l.qte,l.ID  FROM lentc l, eentc e  where l.coded ='" + wcoded + "' and l.codeg = '" + wcodeg + "'  and  l.codea = '" + xcode + "' and e.num=l.num and e.mode='D' and l.codes='" + Program.Societe + "' and l.codee = '" + Program.Exercice + "' and l.codem='" + Program.Magasin + "' ";
                                    ds   = met.recuperer_table(req1, "lentc");



                                    foreach (DataRow dr in ds.Tables["lentc"].Rows)
                                    {
                                        try
                                        {
                                            xtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    req1 = "SELECT distinct l.coded,l.codeg,l.num,l.codea,l.qte,l.ID  FROM lentl l, eentl e  where l.coded ='" + wcoded + "' and l.codeg = '" + wcodeg + "'  and  l.codea = '" + xcode + "' and l.codes='" + Program.Societe + "' and l.codee = '" + Program.Exercice + "' and l.codem='" + Program.Magasin + "'  ";
                                    ds   = met.recuperer_table(req1, "lentl");

                                    foreach (DataRow dr in ds.Tables["lentl"].Rows)
                                    {
                                        try
                                        {
                                            xtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    req1 = "SELECT  coded,codeg,num,codea,qte,ID  FROM lentvc  where coded ='" + wcoded + "' and codeg = '" + wcodeg + "'  and  codea = '" + xcode + "' and codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' ";
                                    ds   = met.recuperer_table(req1, "lentvc");


                                    foreach (DataRow dr in ds.Tables["lentvc"].Rows)
                                    {
                                        try
                                        {
                                            xtqte1 += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte1 += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    req1 = "SELECT  coded,codeg,num,codea,qte,ID  FROM lentvf  where coded ='" + wcoded + "' and codeg = '" + wcodeg + "'  and  codea = '" + xcode + "' and codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "'   ";
                                    ds   = met.recuperer_table(req1, "lentvf");


                                    foreach (DataRow dr in ds.Tables["lentvf"].Rows)
                                    {
                                        try
                                        {
                                            xtqte3 += dr.Field <Double>("qte");
                                        }
                                        catch { }

                                        try
                                        {
                                            wtqte3 += dr.Field <Double>("qte");
                                        }
                                        catch { }
                                    }


                                    //////Sauvegarde Article Dépot

                                    xstk = xqtedep + xtqte2 - xtqte3 - xtqte + xtqte1;

                                    string reqt1 = "";
                                    reqt1 = "Update artdep set qteent = " + xtqte2.ToString().Replace(Program.sep, string.Empty)
                                            + ",qteavrc=" + xtqte1.ToString().Replace(Program.sep, string.Empty)
                                            + ",qtesor=" + xtqte.ToString().Replace(Program.sep, string.Empty)
                                            + ",qteavrf=" + xtqte3.ToString().Replace(Program.sep, string.Empty)
                                            + ",qtestk=" + xstk.ToString().Replace(Program.sep, string.Empty)
                                            + " Where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and codea = '" + xcode + "' and coded ='" + wcoded + "' and codeg='" + wcodeg + "' ";
                                    met.Execute(reqt1);
                                }
                            }

                            wstk = wqtedep + wtqte2 - wtqte3 - wtqte + wtqte1;
                            string reqt2 = "Update artmag set qteent = " + wtqte2.ToString().Replace(Program.sep, string.Empty)
                                           + ",qteavrc=" + wtqte1.ToString().Replace(Program.sep, string.Empty)
                                           + ",qtesor=" + wtqte.ToString().Replace(Program.sep, string.Empty)
                                           + ",qteavrf=" + wtqte3.ToString().Replace(Program.sep, string.Empty)
                                           + ",qtestk=" + wstk.ToString().Replace(Program.sep, string.Empty)
                                           + " Where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and codem='" + Program.Magasin + "' and codea = '" + xcode + "' ";
                            met.Execute(reqt2);
                        }
                    }
                    progressBarX1.Value++;
                }

                progressBarX1.Visible = false;
                MessageBox.Show("Réorganisation  effectuée avec Succés");
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }
Exemple #20
0
        private void buttonX5_Click(object sender, EventArgs e)
        {
            if (Program.ISSaDmin)
            {
                progressBarX1.Value   = 0;
                progressBarX1.Visible = true;
                foreach (DataGridViewRow dgr in mygrid2.Rows)
                {
                    progressBarX1.Maximum = mygrid2.Rows.Count;

                    if (dgr.Cells["choixp"].Value != null)
                    {
                        if ((Boolean)dgr.Cells["choixp"].Value)
                        {
                            double xqtedep = 0, xstk = 0;
                            Double xqteavrc = 0, xqteavrf = 0, xqtesor = 0, xqteent = 0;


                            string req1 = "";

                            string xcode = dgr.Cells["codea"].Value + "";


                            ////// Article Magasin

                            req1 = "SELECT codea,qtedep,qteent,qtesor,qteavrc,qteavrf,qtestk FROM artmag WHERE codes='" + Program.Societe + "' AND codee='" + Program.Exercice + "'  and codea ='" + xcode + "' ";
                            ds   = met.recuperer_table(req1, "artmag");
                            if (ds != null)
                            {
                                if (ds.Tables.Count != 0)
                                {
                                    if (ds.Tables[0].Rows.Count != 0)
                                    {
                                        foreach (DataRow dr in ds.Tables["artmag"].Rows)
                                        {
                                            try
                                            {
                                                xqtedep += dr.Field <double>("qtedep");
                                            }
                                            catch { }

                                            try
                                            {
                                                xqteavrc += dr.Field <double>("qteavrc");
                                            }
                                            catch { }

                                            try
                                            {
                                                xqteavrf += dr.Field <double>("qteavrf");
                                            }
                                            catch { }
                                            try
                                            {
                                                xqteent += dr.Field <double>("qteent");
                                            }
                                            catch { }
                                            try
                                            {
                                                xqtesor += dr.Field <double>("qtesor");
                                            }
                                            catch { }
                                            try
                                            {
                                                xstk += dr.Field <double>("qtestk");
                                            }
                                            catch { }
                                        }

                                        //// Sauvegarde Article Societe


                                        String reqt1 = "Update article set qteent = " + xqteent.ToString().Replace(Program.sep, string.Empty)
                                                       + ",qteavrc=" + xqteavrc.ToString().Replace(Program.sep, string.Empty)
                                                       + ",qtesor=" + xqtesor.ToString().Replace(Program.sep, string.Empty)
                                                       + ",qteavrf=" + xqteavrf.ToString().Replace(Program.sep, string.Empty)
                                                       + ",qtestk=" + xstk.ToString().Replace(Program.sep, string.Empty)
                                                       + ",qtedep=" + xqtedep.ToString().Replace(Program.sep, string.Empty)
                                                       + " Where codes='" + Program.Societe + "' and codee = '" + Program.Exercice + "' and code = '" + xcode + "' ";
                                        met.Execute(reqt1);
                                    }
                                }
                            }
                        }
                    }
                    progressBarX1.Value++;
                }

                progressBarX1.Visible = false;
                MessageBox.Show("Réorganisation  effectuée avec Succés");
            }
            else
            {
                MessageBox.Show("Accés Non Autorisé");
            }
        }