Exemple #1
0
        public void delete_fuel_info(int rec_number)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "delete_fuels";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("rec_number_fuels", SqlDbType.Int)).Value = rec_number;

                cmd.ExecuteNonQuery();
                MessageBox.Show("Fuel's informations deleted succesfully from database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Delete Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Failed Database Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close(); Connex.con.Dispose();
            }
        }
Exemple #2
0
        //SqlConnection con = new SqlConnection("Network Library=DBMSSOCN; Data Source=LENSX,1433; Initial Catalog=bd_daily_security; User Id=sa; [email protected]?;");
        public void load_fuel_info(DataGridView dtg)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                string     requete = "load_fuels";
                SqlCommand cmd     = new SqlCommand(requete, Connex.con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                dtg.DataSource = dt;
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Loading data Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Loading data Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally { Connex.con.Close(); Connex.con.Dispose(); }
        }
Exemple #3
0
        public void load_list_client(ComboBox lst)
        {
            var cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                var cmd = new SqlCommand("get_code_client", Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                var da = new SqlDataAdapter(cmd);
                var dt = new DataTable();
                da.Fill(dt);
                lst.Items.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    lst.Items.Add(dr[0]);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Loading data Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Loading data Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally { Connex.con.Close(); Connex.con.Dispose(); }
        }
Exemple #4
0
        public void delete_client(string client_code)
        {
            var cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "delete_client";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("client_code", SqlDbType.NVarChar)).Value = client_code;

                cmd.ExecuteNonQuery();
                MessageBox.Show("Client's informations deleted succesfully onto database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Deleting failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Failed Database Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close();
            }
        }
Exemple #5
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            Connex cnx = new Connex();

            //var con = new SqlConnection("Network Library=DBMSSOCN; Data Source=EPVSERVER,1433; Initial Catalog=bd_easyschool; User Id=sa; Password=EPVSERVER2016;");
            //var con = new SqlConnection("database=bd_easyschool;server=DESKTOP-DCMFQDO;uid=sa;pwd=EPVSERVER2016");
            //var con = new SqlConnection("Database=L;Server=DESKTOP-DCMFQDO;uid=sa;pwd=EPVSERVER2016");
            if (_dt_control_date.Text == "")
            {
                MessageBox.Show("Complete first the location and then click on button search");
            }
            else
            {
                try
                {
                    if (Connex.con.State == ConnectionState.Closed)
                    {
                        Connex.con.Open();
                    }
                    var cmd = new SqlCommand("daily_situation_manning", Connex.con)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.Add(new SqlParameter("control_date", SqlDbType.Date)).Value = Convert.ToDateTime(_dt_control_date.Text);
                    //cmd.Parameters.Add(new SqlParameter("code_client", SqlDbType.NVarChar)).Value = _cbx_type_guard.Text;
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    //DataTable dt = new DataTable();
                    var     rpt = new _daily_return_manning();
                    DataSet dt  = new DataSet();
                    da.Fill(dt, "daily_situation_manning");
                    rpt.DataSource = dt;
                    //rpt.SetDataSource(dt.Tables["rechercher_pay_bill"]);
                    documentViewer1.DocumentSource = rpt;
                    rpt.CreateDocument();
                    documentViewer1.Refresh();
                    //notifier_message("Classe chargée avec succès", "Chargement reussi");
                }
                catch (Exception et)
                {
                    MessageBox.Show("Erreur : " + et.Message);
                }
                finally { Connex.con.Close(); Connex.con.Dispose(); }
            }
        }
Exemple #6
0
        public void update_manning_info(int rec, int day_number, int night_number, int total_number, string observ, int shift_pat, string type_guard, DateTime control_date, String client)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "update_manning";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("rec_number_manning", SqlDbType.Int)).Value = rec;
                cmd.Parameters.Add(new SqlParameter("day_number", SqlDbType.Int)).Value         = day_number;
                cmd.Parameters.Add(new SqlParameter("night_number", SqlDbType.Int)).Value       = night_number;
                cmd.Parameters.Add(new SqlParameter("total_number", SqlDbType.Int)).Value       = total_number;
                cmd.Parameters.Add(new SqlParameter("observation", SqlDbType.NVarChar)).Value   = observ;
                cmd.Parameters.Add(new SqlParameter("shift_pattern", SqlDbType.Int)).Value      = shift_pat;
                cmd.Parameters.Add(new SqlParameter("type_guard", SqlDbType.NVarChar)).Value    = type_guard;
                cmd.Parameters.Add(new SqlParameter("control_date", SqlDbType.Date)).Value      = control_date;
                cmd.Parameters.Add(new SqlParameter("client_code", SqlDbType.NVarChar)).Value   = client;

                cmd.ExecuteNonQuery();
                MessageBox.Show("Manning's informations updated succesfully onto database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Insertion failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Failed Database Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close(); Connex.con.Dispose();
            }
        }
Exemple #7
0
        public void update_fuel_info(int rec_number, Decimal open_dip, Decimal close_dip, Decimal receipts, Decimal issues, DateTime cntrl_date, String client)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "update_fuels";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("rec_number_fuels", SqlDbType.Int)).Value = rec_number;
                cmd.Parameters.Add(new SqlParameter("open_dip", SqlDbType.Decimal)).Value     = open_dip;
                cmd.Parameters.Add(new SqlParameter("close_dip", SqlDbType.Decimal)).Value    = close_dip;
                cmd.Parameters.Add(new SqlParameter("receipts", SqlDbType.Decimal)).Value     = receipts;
                cmd.Parameters.Add(new SqlParameter("issues", SqlDbType.Decimal)).Value       = issues;
                cmd.Parameters.Add(new SqlParameter("control_date", SqlDbType.Date)).Value    = cntrl_date;
                cmd.Parameters.Add(new SqlParameter("client_code", SqlDbType.NVarChar)).Value = client;

                cmd.ExecuteNonQuery();
                MessageBox.Show("Fuel's informations updated succesfully onto database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Failed Database Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close(); Connex.con.Dispose();
            }
        }
Exemple #8
0
        public void search_fuel_info_by_client(DataGridView dtg, string client_x)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "search_fuels_by_client";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("@client_code", SqlDbType.NVarChar)).Value = client_x;

                cmd.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                dtg.DataSource = dt;
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong!", "Searching Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Will you please see the error code?", "Failed Database Searching", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close(); Connex.con.Dispose();
            }
        }
Exemple #9
0
        public void insert_logs(DateTime control_date, string machine_name, string username_comp, string os_version)
        {
            Connex cnx = new Connex();

            try
            {
                if (Connex.con.State == ConnectionState.Closed)
                {
                    Connex.con.Open();
                }
                const string requete = "insert_logs";
                var          cmd     = new SqlCommand(requete, Connex.con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.Add(new SqlParameter("control_date", SqlDbType.DateTime)).Value  = control_date;
                cmd.Parameters.Add(new SqlParameter("machine_name", SqlDbType.NVarChar)).Value  = machine_name;
                cmd.Parameters.Add(new SqlParameter("username_comp", SqlDbType.NVarChar)).Value = username_comp;
                cmd.Parameters.Add(new SqlParameter("os_version", SqlDbType.NVarChar)).Value    = os_version;

                cmd.ExecuteNonQuery();
                //MessageBox.Show("Connected succesfully to database", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Verify your connection to the Enterprise's LAN!", "Connection failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                var rs = new DialogResult();
                rs = MessageBox.Show("Do you want to see the error code?", "Failed Database Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.Yes)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            finally
            {
                Connex.con.Close(); Connex.con.Dispose();
            }
        }