using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace Prophix___Periodo
{
public partial class frmProphixPeriodo : Form
{
// Variáveis Globais
string StringConexao, Senha;
SqlConnection Conexao;
public frmProphixPeriodo()
{
InitializeComponent();
}
private void ConexaoBD_Open()
{
StringConexao = "Server=XX\XX;Database=;User ID=RM;Password=XX;Trusted_Connection=False";
Conexao = new SqlConnection(StringConexao);
Conexao.Open();
}
private void ConexaoBD_Close()
{
Conexao.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
Senha = "rmenella";
dtpInicial.Value = DateTime.Now.Date;
dtpFinal.Value = DateTime.Now.Date;
ConexaoBD_Open();
SqlCommand QueryColigada = new SqlCommand("SELECT CODCOLIGADA, NOMEFANTASIA FROM GCOLIGADA ORDER BY CODCOLIGADA", Conexao);
SqlDataReader DadosColigada = QueryColigada.ExecuteReader();
while (DadosColigada.Read())
{
cbBox.Items.Add(DadosColigada["CODCOLIGADA"] + " - " + DadosColigada["NOMEFANTASIA"]);
}
ConexaoBD_Close();
}
private void btnExecutar_Click(object sender, EventArgs e)
{
int ColigadaSelecionada;
DateTime DataInicial, DataFinal;
DataInicial = dtpInicial.Value;
DataFinal = dtpFinal.Value;
ColigadaSelecionada = cbBox.SelectedIndex;
//label1.Text = Convert.ToString(ColigadaSelecionada);
lblStatus.Text = "EM EXECUÇÃO";
try
{
ConexaoBD_Open();
SqlCommand StoredProc = new SqlCommand("SP_INTEGRACAO_RM_PROPHIX_PERIODO", Conexao);
StoredProc.CommandType = CommandType.StoredProcedure;
StoredProc.Parameters.AddWithValue("@CODCOLIGADA", ColigadaSelecionada);
StoredProc.Parameters.AddWithValue("@DATAINICIAL", DataInicial);
StoredProc.Parameters.AddWithValue("@DATAFINAL", DataFinal);
StoredProc.Parameters.AddWithValue("@CODHISTP", "");
StoredProc.CommandTimeout = 1000;
StoredProc.ExecuteNonQuery();
lblStatus.Text = "EXECUTADO COM SUCESSO!";
}
catch (SqlException ErroSQL)
{
lblStatus.Text = ErroSQL.Message;
}
finally
{
ConexaoBD_Close();
}
}
private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//label1.Text = Convert.ToString(cbBox.SelectedIndex);
}
private void frmProphixPeriodo_FormClosed(object sender, FormClosedEventArgs e)
{
}
private void maskedTextBox1_MaskInputRejected_1(object sender, MaskInputRejectedEventArgs e)
{
}
private void maskedTextBox1_TextChanged(object sender, EventArgs e)
{
if (mtbSenha.Text == Convert.ToString(Senha))
{
btnExecutar.Enabled = true;
}
else
{
btnExecutar.Enabled = false;
}
}
}
}