コード例 #1
0
        public void EditarEstoque()
        {
            DS_Mensagem = "";

            SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = ModelConexao.Conexao;
                SqlCon.Open();
                DS_Mensagem = "";

                sqlCommand = new SqlCommand(
                    "UPDATE TB_Estoque SET " +
                    "QTDE_Estoque +=  '" + QTDE_Estoque.ToString(CultureInfo.GetCultureInfo("en-US")) + "'" +
                    "WHERE ID_Insumo = '" + ID_Insumo + "'",
                    SqlCon);


                int result = sqlCommand.ExecuteNonQuery();

                DS_Mensagem = result > 0 ? "OK" : "Erro ao alterar";
            }
            catch (Exception e)
            {
                DS_Mensagem = e.Message;
            }
            finally
            {
                sqlCommand.Dispose();
                SqlCon.Close();
            }
        }
コード例 #2
0
        // Método inserir
        public void InserirEstoque()
        {
            SqlCon = new SqlConnection();

            try
            {
                DS_Mensagem = "";

                SqlCon.ConnectionString = ModelConexao.Conexao;
                SqlCon.Open();
                sqlCommand = new SqlCommand(
                    "INSERT INTO TB_Estoque ( " +
                    "ID_Insumo, " +
                    "QTDE_Estoque) " +
                    "VALUES ( " +
                    "'" + ID_Insumo + "', " +
                    "'" + QTDE_Estoque.ToString(CultureInfo.GetCultureInfo("en-US")) + "'",
                    SqlCon);
                int result = sqlCommand.ExecuteNonQuery();
                DS_Mensagem = result > 0 ? "OK" : "Erro ao cadastrar";
            }
            catch (Exception e)
            {
                DS_Mensagem = e.Message;
            }
            finally
            {
                sqlCommand.Dispose();
                SqlCon.Close();
            }
        }