Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: better way to Linqify this ? Pin
BillWoodruff11-Jan-16 10:27
professionalBillWoodruff11-Jan-16 10:27 
GeneralRe: better way to Linqify this ? Pin
Richard Deeming11-Jan-16 10:52
mveRichard Deeming11-Jan-16 10:52 
GeneralRe: better way to Linqify this ? Pin
BillWoodruff12-Jan-16 7:38
professionalBillWoodruff12-Jan-16 7:38 
GeneralRe: better way to Linqify this ? Pin
Richard Deeming12-Jan-16 7:49
mveRichard Deeming12-Jan-16 7:49 
GeneralRe: better way to Linqify this ? Pin
BillWoodruff12-Jan-16 20:37
professionalBillWoodruff12-Jan-16 20:37 
QuestionOne button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Member 114494477-Jan-16 22:49
Member 114494477-Jan-16 22:49 
AnswerRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
OriginalGriff7-Jan-16 23:16
mveOriginalGriff7-Jan-16 23:16 
GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Member 114494478-Jan-16 1:08
Member 114494478-Jan-16 1:08 
In the following code, the button 'bt_gravar_click' which belongs to a toolstrip bar doesn´t fill correctly the check boxes whereas the button ' bt_preencher', which is a normal button in datagrid, does. The code is not well indented.

C#
private void bt_gravar_Click(object sender, EventArgs e)
        {
            
         Gravar();          
           
        }

 private void bt_preencher_Click(object sender, EventArgs e)
        {
         Gravar();      
            
        }

public void Gravar()
{
BD_Conexao();
if (grid_lic.CurrentRow.Cells[3].Value.ToString() != "" | grid_lic.CurrentRow.Cells[3].Value.ToString() == "True")

   bloqueador = 1;
else
   bloqueador = 0;

   
if (grid_lic.CurrentRow.Cells[7].Value.ToString() != "" | grid_lic.CurrentRow.Cells[7].Value.ToString() == "True")
   EArtigo = 1;
else
   EArtigo = 0;

string Cmd = "Select * from lojas where NIF ='" + grid_lic.CurrentRow.Cells[1].Value + "' and loja ='" + grid_lic.CurrentRow.Cells[2].Value + "'";

 OdbcCommand cm2 = new OdbcCommand(Cmd, con);
 OdbcDataReader dr = cm2.ExecuteReader();

string cmd = "insert into licenciamentoloja (bloqueador, EArtigo) values (?, ?)";

OdbcCommand cm = new OdbcCommand(cmd, con);

cm.Parameters.AddWithValue("@bloqueador", bloqueador);
cm.Parameters.AddWithValue("@EArtigo", EArtigo);

cm.ExecuteNonQuery();

Consulta()

}

public void Consulta()
{
          
 con = new OdbcConnection("driver= {MySQL ODBC 5.1 Driver};server=xxx; database=licenciamento; uid=estagio; password=1234; option = 3 ");
            
con.Open();

OdbcCommand Command = con.CreateCommand();
 Command.CommandText = "select licenciamentoloja.bloqueador, licenciamentoloja.Artigo from licenciamentoloja;" 

Command.CommandType = CommandType.Text;
Command.Connection = con;

OdbcDataAdapter adapter = new OdbcDataAdapter();
adapter.SelectCommand = Command;
_ds = new DataSet();
 dt = _ds.Tables["filtro"];
 adapter.Fill(_ds, "filtro");
 grid_lic.DataSource = _ds;
 grid_lic.DataMember = _ds.Tables[0].TableName;
 grid_lic.DataMember = "filtro";
}

  public void BD_Conexao()
  {
  try
     {
      OdbcConnection con = new OdbcConnection("driver= {MySQL ODBC 5.1 Driver};server=xxx; database=licenciamento; uid=estagio; password=1234; option = 3 ");
      
      con.Open();
     }

  catch (Exception ex)
  {
   Console.WriteLine("Erro na ligação à base de dados. \n{0}", ex.Message);

    return;
  }

    }

GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
OriginalGriff8-Jan-16 1:22
mveOriginalGriff8-Jan-16 1:22 
GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Member 114494478-Jan-16 1:51
Member 114494478-Jan-16 1:51 
GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Richard MacCutchan8-Jan-16 2:53
mveRichard MacCutchan8-Jan-16 2:53 
GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Dave Kreskowiak8-Jan-16 3:58
mveDave Kreskowiak8-Jan-16 3:58 
SuggestionRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Richard Deeming8-Jan-16 2:08
mveRichard Deeming8-Jan-16 2:08 
GeneralRe: One button from the toolstrip bar not updating checkboxes from the datagrid columns Pin
Member 114494478-Jan-16 6:04
Member 114494478-Jan-16 6:04 
Questionparse xml Pin
MaheshSharma7-Jan-16 16:33
MaheshSharma7-Jan-16 16:33 
SuggestionRe: parse xml Pin
dan!sh 7-Jan-16 16:48
professional dan!sh 7-Jan-16 16:48 
AnswerRe: parse xml Pin
Richard MacCutchan7-Jan-16 22:10
mveRichard MacCutchan7-Jan-16 22:10 
AnswerRe: parse xml Pin
BillWoodruff8-Jan-16 0:49
professionalBillWoodruff8-Jan-16 0:49 
QuestionC# swf decompiler Pin
Member 122071957-Jan-16 5:31
Member 122071957-Jan-16 5:31 
AnswerRe: C# swf decompiler Pin
OriginalGriff7-Jan-16 5:47
mveOriginalGriff7-Jan-16 5:47 
Questionstop a task Pin
caradri6-Jan-16 23:34
caradri6-Jan-16 23:34 
AnswerRe: stop a task Pin
Simon_Whale6-Jan-16 23:42
Simon_Whale6-Jan-16 23:42 
AnswerRe: stop a task Pin
Pete O'Hanlon7-Jan-16 0:04
mvePete O'Hanlon7-Jan-16 0:04 
GeneralRe: stop a task Pin
caradri7-Jan-16 1:42
caradri7-Jan-16 1:42 
GeneralRe: stop a task Pin
Pete O'Hanlon7-Jan-16 1:50
mvePete O'Hanlon7-Jan-16 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.