コード例 #1
0
        private void btn_Valider_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Etes vous sûres de valider la commande?\nNB: Une commande validée ne peut pas être modifiée!", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    DCOMMANDE_FOURNISSEUR cmd = new DCOMMANDE_FOURNISSEUR();
                    cmd.CODE_COMMANDE_FOURNISSEUR = txt_NUM_COMMANDE.Text;
                    cmd.VALIDE          = true;
                    cmd.USER_VALIDATION = Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user);
                    cmd.DATE_VALIDATION = CLIENT_APP_PARAM.gcws.getDateS();

                    RESULT_QUERY res = new RESULT_QUERY();
                    res = CLIENT_APP_PARAM.gcws.validerCOMMANDE_FOURNISSEUR(cmd);
                    if (res.OK)
                    {
                        ValidateChanges = true;
                        ((DataRowView)bsCommande.Current)["Valide"]          = "True";
                        ((DataRowView)bsCommande.Current)["USER_VALIDATION"] = cmd.USER_VALIDATION;
                        ((DataRowView)bsCommande.Current)["DATE_VALIDATION"] = cmd.DATE_VALIDATION;
                        MessageBox.Show("Commande validée avec succès.");
                        dS_MOUV1.V_CMD_FR.Clear();
                        dS_MOUV1.V_CMD_FR.ImportRow((bsCommande.DataSource as DataTable).Select("CODE_COMMANDE_FOURNISSEUR like '" + txt_NUM_COMMANDE.Text + "'")[0]);

                        if (MessageBox.Show("Voulez vous imprimer la commande?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            ReportDocument rpt = new CHM_RPT_CMD_FR();
                            rpt.SetDataSource(dS_MOUV1);
                            rpt.SetParameterValue("entete", CLIENT_APP_PARAM.entete);
                            rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter;
                            rpt.PrintToPrinter(1, true, 0, 0);
                        }
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(res.MESSAGE, this.Text);
                        return;

                        ValidateChanges = false;
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, this.Text);
            }
        }
コード例 #2
0
        void onValidate(object sender, EventArgs e)
        {
            #region test
            if (cbx_magazin.SelectedValue == null)
            {
                MessageBox.Show("Veuillez sélectionner le dépot!");
                return;
            }

            if (cbx_magazin.SelectedValue == null)
            {
                MessageBox.Show("Veuillez sélectionner le Fournisseur!");
                return;
            }

            if (dS_MOUV1.V_LG_CMD_FR.Rows.Count < 1)
            {
                MessageBox.Show("Veuillez sélectionner les articles à commander!");
                return;
            }
            #endregion
            try
            {
                if (dS_MOUV1.V_LG_CMD_FR.Rows.Count > 0)
                {
                    DCOMMANDE_FOURNISSEUR cmd = new DCOMMANDE_FOURNISSEUR();
                    cmd.CODE_COMMANDE_FOURNISSEUR = txt_NUM_COMMANDE.Text;
                    cmd.CODE_FOURNISSEUR          = _code_fournisseur;
                    cmd.REMARQUE = txt_REMARQUE.Text;
                    cmd.DATE_COMMANDE_FOURNISSEUR            = dtp_DATE_COMMANDE.Value;
                    cmd.PRIORITE_COMMANDE_FOURNISSEUR        = chbx_priorite.Checked;
                    cmd.DATE_EXPIRATION_COMMANDE_FOURNISSEUR = chbx_priorite.Checked ? dtp_DATE_EXPIRATION.Value : Convert.ToDateTime("01/01/1900");
                    cmd.MOIS_CMDFR        = dtp_DATE_COMMANDE.Value.Month;
                    cmd.ANNEE_CMDFR       = dtp_DATE_COMMANDE.Value.Year;
                    cmd.ADRESSE_LIVRAISON = txt_ADRESSE_LIVRAISON.Text;
                    cmd.CODE_FOURNISSEUR  = Convert.ToDecimal(txt_fournisseur.Tag);
                    cmd.CODE_MAG          = Convert.ToDecimal(cbx_magazin.SelectedValue);
                    cmd.CODE_USER         = Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user);
                    cmd.CONTACT           = txt_CONTACT.Text;
                    cmd.DATE_VALIDATION   = Convert.ToDateTime("01/01/1900");
                    cmd.TEL_CONTACT       = txt_TEL_CONTACT.Text;



                    DataTable dtDetail = new DataTable("details");
                    foreach (DataColumn dc in dS_MOUV1.V_LG_CMD_FR.Columns)
                    {
                        DataColumn c = new DataColumn();
                        c.Caption    = dc.Caption;
                        c.ColumnName = dc.ColumnName;
                        c.DataType   = dc.DataType;
                        dtDetail.Columns.Add(c);
                    }
                    foreach (DataRow drdetail in dS_MOUV1.V_LG_CMD_FR.Rows)
                    {
                        dtDetail.ImportRow(drdetail);
                    }


                    RESULT_QUERY res = new RESULT_QUERY();
                    if (cmd.CODE_COMMANDE_FOURNISSEUR == "")
                    {
                        res = CLIENT_APP_PARAM.gcws.ajouteCOMMANDE_FOURNISSEUR(cmd, dtDetail);
                        if (res.OK)
                        {
                            DataRowView drv = (DataRowView)bsCommande.Current;
                            drv["CODE_USER"] = Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user);
                            drv["CODE_COMMANDE_FOURNISSEUR"] = res.CODE;
                            drv["VALIDE"]         = "False";
                            txt_NUM_COMMANDE.Text = res.CODE;
                            foreach (DataRow dr in dS_MOUV1.V_LG_CMD_FR.Rows)
                            {
                                dr["CODE_COMMANDE_FOURNISSEUR"] = res.CODE;
                                dS_MOUV1.V_LG_CMD_FR.AcceptChanges();
                            }

                            ValidateChanges = true;
                            bsCommande.EndEdit();
                            (bsCommande.DataSource as DataTable).AcceptChanges();
                            bsCommande.Position = bsCommande.Find("CODE_COMMANDE_FOURNISSEUR", res.CODE);
                            bsCommande_PositionChanged(null, null);
                            dS_MOUV1.V_CMD_FR.Clear();
                            dS_MOUV1.V_CMD_FR.ImportRow((bsCommande.DataSource as DataTable).Select("CODE_COMMANDE_FOURNISSEUR like '" + res.CODE + "'")[0]);

                            if (MessageBox.Show("Voulez vous une copie test de la commande?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                ReportDocument rpt = new CHM_RPT_CMD_FR();
                                rpt.SetDataSource(dS_MOUV1);
                                rpt.SetParameterValue("entete", CLIENT_APP_PARAM.entete);
                                rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter;
                                rpt.PrintToPrinter(1, true, 0, 0);
                            }
                            if (MessageBox.Show("Voulez vous fermer la commande?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(res.MESSAGE, this.Text);
                            ValidateChanges = false;
                            return;
                        }
                    }
                    else
                    {
                        res = CLIENT_APP_PARAM.gcws.modifieCOMMANDE_FOURNISSEUR(cmd, dtDetail);
                        if (res.OK)
                        {
                            DataRowView drv = (DataRowView)bsCommande.Current;
                            drv["CODE_USER"] = Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user);

                            txt_NUM_COMMANDE.Text = res.CODE;

                            ValidateChanges = true;
                            if (MessageBox.Show("Voulez vous une copie test de la commande?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                //Impression
                            }
                            if (MessageBox.Show("Voulez vous fermer la commande?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show(res.MESSAGE, this.Text);
                            ValidateChanges = false;
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Commandes vide!\nVeuillez sélectionner les articles à commander.", this.Text);
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, this.Text);
            }
        }