示例#1
0
        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            int count = gridView1.DataRowCount;

            if (count != 0 && gridView1.FocusedRowHandle != DevExpress.XtraGrid.GridControl.AutoFilterRowHandle)
            {
                System.Data.DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle);
                id_fact = Convert.ToInt32(row[1].ToString());
                //FactureVente fatvent = new FactureVente(id_fact);
                //fatvent.ShowDialog();
                FactureReport report = new FactureReport(id_fact);
                report.ShowPreview();
                //string dt = row[2].ToString();
                //num_fact = Convert.ToDateTime(dt).Year.ToString().Substring(2, 2) + " /" + row[0].ToString();
                //facturing f = new facturing();
                //f.ShowDialog();
            }
        }
示例#2
0
        private void simpleButton5_Click(object sender, EventArgs e)
        {
            Tnumfact.Visible      = false;
            simpleButton5.Visible = false;
            labelControl1.Visible = false;
            labelControl2.Visible = false;
            dateEdit1.Visible     = false;
            labelControl3.Visible = false;
            textEdit1.Visible     = false;
            string num_fact = Tnumfact.Text;
            int    num_f    = 0;

            int.TryParse(Tnumfact.Text, out num_f);
            DataTable dt_fact_n = fun.GetFactByNum(num_f);

            if (dt_fact_n.Rows.Count > 0)
            {
                XtraMessageBox.Show("Il existe une facture avec ce numéro");
            }
            else
            {
                if (dateEdit1.Text == "")
                {
                    MessageBox.Show("Entrer la date du facture");
                }
                else
                {
                    data = new DataTable();
                    data.Clear();
                    data.Columns.Add("code piece");
                    data.Columns.Add("code_art");
                    data.Columns.Add("libelle_piece");
                    data.Columns.Add("quantite_piece");
                    data.Columns.Add("id_clt");
                    data.Columns.Add("etat");
                    data.Columns.Add("puv");
                    data.Columns.Add("totvente");
                    data.Columns.Add("id_commande");
                    data.Columns.Add("remise");
                    data.Columns.Add("ttva");
                    data.Columns.Add("unit");

                    id_factt = get_maxfact() + 1;

                    if (gridView1.GetSelectedRows().Count() != 0)
                    {
                        totalfacturettc = 0;
                        totalfactureht  = 0;
                        string        tva = "0", timbre = "0";
                        double        tt_ht = 0, tt_ttc = 0, prix = 0;
                        List <string> l_bl = new List <string>();
                        foreach (int i in gridView1.GetSelectedRows())
                        {
                            DataTable datatable = new DataTable();
                            DataRow   row       = gridView1.GetDataRow(i);
                            DataTable dt        = new DataTable();
                            dt        = fun.getbl(Convert.ToInt32(row[0].ToString()));
                            id_clt    = Convert.ToInt32(dt.Rows[0][2].ToString());
                            client    = dt.Rows[0][4].ToString();
                            idfcmd    = Convert.ToInt32(dt.Rows[0][11].ToString());
                            idbl      = Convert.ToInt32(dt.Rows[0][0].ToString());
                            datatable = fun.get_Allprodbybl(row[0].ToString());
                            l_bl.Add(row[13].ToString());
                            if (dt.Rows[0][5] != DBNull.Value)
                            {
                                totalfactureht += Convert.ToDouble(dt.Rows[0][5].ToString());
                            }
                            else
                            {
                                totalfactureht += 0;
                            }
                            if (dt.Rows[0][6] != DBNull.Value)
                            {
                                totalfacturettc += Convert.ToDouble(dt.Rows[0][6].ToString());
                            }
                            else
                            {
                                totalfacturettc += 0;
                            }


                            if (datatable.Rows.Count != 0)
                            {
                                foreach (DataRow row1 in datatable.Rows)
                                {
                                    //DataRow newpc = data.NewRow();
                                    //newpc["code piece"] = row1[0];
                                    //newpc["code_art"] = row1[1];
                                    //newpc["libelle_piece"] = row1[2];
                                    //newpc["quantite_piece"] = Convert.ToDouble(row1[3].ToString().Replace('.', ','));
                                    //newpc["id_clt"] = row1[4];
                                    //newpc["etat"] = "validée";
                                    //newpc["puv"] = row1[6];
                                    //newpc["totvente"] = row1[7];
                                    //newpc["id_commande"] = row1[8];
                                    //newpc["remise"] = row1[9];
                                    //newpc["ttva"] = row1[10];
                                    //newpc["unit"] = row1[11];

                                    //data.Rows.Add(newpc);
                                    timbre  = dt.Rows[0][9].ToString();
                                    prix    = double.Parse(row1[3].ToString().Replace('.', ',')) * double.Parse(row1[6].ToString().Replace('.', ','));
                                    prix    = prix - ((prix * double.Parse(row1[9].ToString().Replace('.', ',')) / 100));
                                    tt_ht  += prix;
                                    prix    = prix + ((prix * double.Parse(row1[10].ToString().Replace('.', ',')) / 100));
                                    tt_ttc += prix;
                                    DataTable dt_piec = fun.get_piece_fact(id_factt, row1[1].ToString());
                                    double    qt = 0, pvv = 0;
                                    if (dt_piec.Rows.Count > 0)
                                    {
                                        qt  = double.Parse(dt_piec.Rows[0]["quantite_piece_u"].ToString().Replace('.', ','));
                                        pvv = double.Parse(dt_piec.Rows[0]["pv"].ToString().Replace('.', ','));
                                        qt  = qt + Convert.ToDouble(row1[3].ToString().Replace('.', ','));
                                        pvv = pvv + double.Parse(row1[7].ToString().Replace('.', ','));
                                        string dt_up = fun.update_piece_factt(qt, row1[1].ToString(), id_factt, pvv);
                                    }
                                    else
                                    {
                                        fun.insert_piecee_fact(row1[2].ToString(), row1[1].ToString(), Convert.ToDouble(row1[3].ToString().Replace('.', ',')), row1[4].ToString(), row1[5].ToString(), id_factt, row1[6].ToString(), row1[7].ToString(), dt.Rows[0][12].ToString(), row1[9].ToString(), row1[10].ToString(), row1[11].ToString());
                                    }
                                    tva  = row1[10].ToString();
                                    prix = 0;
                                }
                            }
                        }
                        string dd = dateEdit1.Text.Substring(0, 10);//.ToString();
                        dd       = dd.Substring(0, 10);
                        num_fact = Tnumfact.Text;
                        string list_bl = "";
                        for (int g = 0; g < l_bl.Count; g++)
                        {
                            list_bl += l_bl[g].Trim() + "/";
                        }
                        if (textEdit1.Text == "")
                        {
                            list_bl = list_bl.Substring(0, list_bl.Count() - 1);
                        }
                        else
                        {
                            list_bl += textEdit1.Text;// list_bl.Substring(0, list_bl.Count() - 1);
                        }
                        fun.insertintofacturevente(id_clt.ToString(), dd, "en cours", client, idfcmd.ToString(), tt_ttc.ToString("0.000"), "0", tt_ht.ToString("0.000"), timbre, tva, "0", "0", num_fact, idbl, list_bl);
                    }
                    FactureReport report = new FactureReport(id_factt);
                    report.ShowPreview();
                    //num_facture =  NumFact().ToString();
                    //facture fact = new facture();
                    //fact.Show();
                }
            }
            Tnumfact.Text = "";
        }
示例#3
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            try
            {
                if (Idfact != 0)
                {
                    if (dateEdit1.Text == "")
                    {
                        MessageBox.Show("Entrer la date du facture");
                    }
                    else
                    {
                        updateFacture();
                        this.Close();
                        FactureReport report = new FactureReport(Idfact);
                        report.ShowPreview();
                    }
                }
                else
                {
                    int id_factt = get_maxfact() + 1;
                    int num_f    = 0;
                    int.TryParse(Tnumfact.Text, out num_f);
                    DataTable dt_fact_n = fun.GetFactByNum(num_f);
                    if (dt_fact_n.Rows.Count > 0)
                    {
                        XtraMessageBox.Show("Il existe une facture avec ce numéro");
                    }
                    else
                    {
                        if (dateEdit1.Text == "")
                        {
                            MessageBox.Show("Entrer la date du facture");
                        }
                        else
                        {
                            string dd = dateEdit1.Text.Substring(0, 10);//.ToString();
                            dd = dd.Substring(0, 10);
                            DataRowView rowView1 = (DataRowView)lookUpEdit1.GetSelectedDataRow();
                            DataRow     row = rowView1.Row;
                            int         id_clt = int.Parse(row[0].ToString());
                            string      client = row[1].ToString();
                            string      tva = "";
                            double      prix = 0, tt_ht = 0;
                            for (int i = 0; i < darttab.Rows.Count; i++)
                            {
                                DataRow row1 = gridView1.GetDataRow(i);
                                fun.insert_piecee_fact(row1["libelle_piece"].ToString(), row1["code_art"].ToString(), Convert.ToDouble(row1["quantite_piece"].ToString().Replace('.', ',')), id_clt.ToString(), row1["etat"].ToString(), id_factt, row1["puv"].ToString(), row1["totvente"].ToString(), id_factt.ToString(), row1["remise"].ToString(), row1["ttva"].ToString(), row1["unit"].ToString());
                                if (row1["ttva"].ToString() == "")
                                {
                                    tva = "0";
                                }
                                else
                                {
                                    tva = row1["ttva"].ToString();
                                }
                                prix   = double.Parse(row1["quantite_piece"].ToString().Replace('.', ',')) * double.Parse(row1["puv"].ToString().Replace('.', ','));
                                prix   = prix - ((prix * double.Parse(row1["remise"].ToString().Replace('.', ',')) / 100));
                                tt_ht += prix;
                            }
                            fun.insertintofacturevente(id_clt.ToString(), dd, "en cours", client, "0", prixtotc.ToString("0.000"), "0", tt_ht.ToString("0.000"), textBox5.Text, tva, "0", "0", Tnumfact.Text, _LidBl.First(), textEdit1.Text);

                            //
                        }
                    }
                    this.Close();
                    FactureReport report = new FactureReport(id_factt);
                    report.ShowPreview();
                }
            }
            catch (Exception ed)
            {
                MessageBox.Show("Vérifier les données entrer");
            }
        }