예제 #1
0
        public List <StocDepozit> GetListaStocDepozitRepo()
        {
            List <StocDepozit> listaDepozit = new List <StocDepozit>();

            using (MySqlConnection conn = new MySqlConnection(Ada.Properties.Settings.Default.connString))
            {
                if (conn == null)
                {
                    throw new Exception("Connection String is Null. Set the value of Connection String in Ada->Properties-?Settings.settings");
                }
                MySqlCommand query = new MySqlCommand("SELECT * from stoc_depozit", conn);
                conn.Open();
                MySqlDataAdapter sqlDataAdapter = new MySqlDataAdapter(query);
                DataTable        dataTable      = new DataTable();
                sqlDataAdapter.Fill(dataTable);

                foreach (DataRow row in dataTable.Rows)
                {
                    StocDepozit stocDepozit = new StocDepozit();
                    stocDepozit.Codmat        = row["CODMAT"].ToString();
                    stocDepozit.Sf            = row["SF"].ToString();
                    stocDepozit.Denmat        = row["DENMAT"].ToString();
                    stocDepozit.Raft          = row["RAFT"].ToString();
                    stocDepozit.CodBare       = row["COD_BARE"].ToString();
                    stocDepozit.PretCumparare = row["PRET_CUMP"].ToString();
                    stocDepozit.PretTV_Aman   = row["PRETV_AMAN"].ToString();
                    stocDepozit.Clasa         = row["CLASA"].ToString();
                    listaDepozit.Add(stocDepozit);
                }

                return(listaDepozit);
            }
        }
예제 #2
0
        /*
         * Function: Add new record to the Database
         * with the help of stored procedure
         */
        public void AddNewRecord(StocDepozit stocDepozit)
        {
            using (MySqlConnection conn = new MySqlConnection(Ada.Properties.Settings.Default.connString))
            {
                if (conn == null)
                {
                    throw new Exception("Connection String is Null. Set the value of Connection String in MovieCatalog->Properties-?Settings.settings");
                }
                else if (stocDepozit == null)
                {
                    throw new Exception("The passed argument 'movieRecord' is null");
                }

                conn.Open();
                using (MySqlCommand command = new MySqlCommand("INSERT INTO borderou (factura, website ) VALUES ("
                                                               + stocDepozit.Raft + ",'" + stocDepozit.Sf + "')", conn))
                {
                    command.ExecuteNonQuery();
                }
                conn.Close();
            }
        }