Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (_bs_liste_br_fr.Current != null)
                {
                    ReportDocument rpt = new BON_RECEPTION.RPT_BR_FR();
                    //DataTable dt = CLIENT_APP_PARAM.GEST.P_BR_FR.IMPRIMER_BRECEP_FR((decimal)(_bs_liste_br_fr.Current as DataRowView)["CODE_BRECEP"]);
                    DataTable dt = CLIENT_APP_PARAM.gcws.IMPRIMER_BRECEP_FR((decimal)(_bs_liste_br_fr.Current as DataRowView)["CODE_BRECEP"]);
                    //rpt.SetDataSource(CLIENT_APP_PARAM.GEST.P_BR_FR.IMPRIMER_BRECEP_FR((decimal)(_bs_liste_br_fr.Current as DataRowView)["CODE_BRECEP"]));
                    rpt.SetDataSource(CLIENT_APP_PARAM.gcws.IMPRIMER_BRECEP_FR((decimal)(_bs_liste_br_fr.Current as DataRowView)["CODE_BRECEP"]));

                    CHM_ETATS f = new CHM_ETATS();
                    f.CHM_Aperçu_document.ReportSource = rpt;
                    f.MdiParent = CLIENT_APP_PARAM.Fenetre_principale;
                    f.Show();
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
        }
Example #2
0
        private void buttonENREGISTRER_Click(object sender, EventArgs e)
        {
            #region Validation des champs
            errorProvider1.SetError(txt_fournisseur, "");
            {
                if (txt_fournisseur.Text.Trim() == "")
                {
                    errorProvider1.SetError(button2, "Saisir Fournisseur!");
                    button2.Focus();
                    return;
                }
            }

            errorProvider1.SetError(cbx_magazin, "");
            {
                if (cbx_magazin.SelectedValue == null)
                {
                    errorProvider1.SetError(cbx_magazin, "Sélectionner le Magasin!");
                    cbx_magazin.Focus();
                    return;
                }
            }

            errorProvider1.SetError(txt_NUM_ORDER, "");
            {
                if (txt_NUM_ORDER.Text.Trim() == "")
                {
                    errorProvider1.SetError(txt_NUM_ORDER, "N° de BL Fournisseur manquant!");
                    txt_NUM_ORDER.Focus();
                    txt_NUM_ORDER.Select();
                    return;
                }
            }

            errorProvider1.SetError(gridControl1, "");
            {
                if (dS_MOUV1.LG_BR_FR.Rows.Count == 0)
                {
                    errorProvider1.SetError(gridControl1, "Rien à enregistrer");
                    return;
                }
            }
            #endregion

            if (MessageBox.Show("Etes vous sûres d'enregistrer le bon de réception?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                _dt_details_br = new DataTable("dtDetails");
                foreach (DataColumn c in dS_MOUV1.LG_BR_FR.Columns)
                {
                    DataColumn newCol = new DataColumn();
                    newCol.ColumnName = c.ColumnName;
                    newCol.DataType   = c.DataType;

                    _dt_details_br.Columns.Add(newCol);
                }

                foreach (DataRow dr in dS_MOUV1.LG_BR_FR.Rows)
                {
                    _dt_details_br.ImportRow(dr);
                }
                if (_CODE_BRECEP == -1)
                {
                    try
                    {
                        Cursor = Cursors.WaitCursor;
                        Application.DoEvents();
                        //CHM_GESTION_COMERCIALE.RESULT_QUERY res = CLIENT_APP_PARAM.GEST.P_BR_FR.INSERT_BR_FR(txt_NUM_ORDER.Text, _code_fournisseur, (decimal)cbx_magazin.SelectedValue, dateTimePicker1.Value, Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user), NP.Value, nud_pourcentage_remise.Value, _dt_details_br);
                        CHMGC.RESULT_QUERY res = CLIENT_APP_PARAM.gcws.INSERT_BR_FR(txt_NUM_ORDER.Text, _code_fournisseur, (decimal)cbx_magazin.SelectedValue, dateTimePicker1.Value, Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user), lb_MNT_HT.Value, nud_pourcentage_remise.Value, _dt_details_br);
                        if (res.OK)
                        {
                            MessageBox.Show(res.MESSAGE, "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            buttonENREGISTRER.Enabled = false;
                            if (OnSave != null)
                            {
                                OnSave(_CODE_BRECEP);
                            }

                            if (MessageBox.Show("Vouler vous visualiser le bon de réception?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                ReportDocument rpt = new BON_RECEPTION.RPT_BR_FR();
                                //DataTable dt = CLIENT_APP_PARAM.GEST.P_BR_FR.IMPRIMER_BRECEP_FR(Convert.ToDecimal(res.CODE));
                                DataTable dt = CLIENT_APP_PARAM.gcws.IMPRIMER_BRECEP_FR(Convert.ToDecimal(res.CODE));
                                rpt.SetDataSource(dt);

                                CHM_ETATS f = new CHM_ETATS();
                                f.CHM_Aperçu_document.ReportSource = rpt;
                                f.MdiParent = CLIENT_APP_PARAM.Fenetre_principale;
                                f.Show();
                            }


                            Close();
                        }
                        else
                        {
                            MessageBox.Show(res.MESSAGE, "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    finally
                    {
                        this.Cursor = Cursors.Default;
                    }
                }
                else
                {
                    try
                    {
                        Cursor = Cursors.WaitCursor;
                        Application.DoEvents();
                        //CHM_GESTION_COMERCIALE.RESULT_QUERY res = CLIENT_APP_PARAM.GEST.P_BR_FR.UPDATE_BR_FR(_CODE_BRECEP, txt_NUM_ORDER.Text, _code_fournisseur, (decimal)cbx_magazin.SelectedValue, dateTimePicker1.Value, Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user), NP.Value, nud_pourcentage_remise.Value, _dt_details_br);
                        CHMGC.RESULT_QUERY res = CLIENT_APP_PARAM.gcws.UPDATE_BR_FR(_CODE_BRECEP, txt_NUM_ORDER.Text, _code_fournisseur, (decimal)cbx_magazin.SelectedValue, dateTimePicker1.Value, Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user), lb_MNT_HT.Value, nud_pourcentage_remise.Value, _dt_details_br);
                        if (res.OK)
                        {
                            MessageBox.Show(res.MESSAGE, "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            buttonENREGISTRER.Enabled = false;
                            ReportDocument rpt = new BON_RECEPTION.RPT_BR_FR();
                            //DataTable dt = CLIENT_APP_PARAM.GEST.P_BR_FR.IMPRIMER_BRECEP_FR(Convert.ToDecimal(res.CODE));
                            DataTable dt = CLIENT_APP_PARAM.gcws.IMPRIMER_BRECEP_FR(Convert.ToDecimal(res.CODE));
                            rpt.SetDataSource(dt);

                            CHM_ETATS f = new CHM_ETATS();
                            f.CHM_Aperçu_document.ReportSource = rpt;
                            f.MdiParent = CLIENT_APP_PARAM.Fenetre_principale;
                            f.Show();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show(res.MESSAGE, "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    finally
                    {
                        this.Cursor = Cursors.Default;
                    }
                }
            }
        }