Exemplo n.º 1
0
 //this function is used for search
 public void loaddatacourse(string whereclause)
 {
     listView1.Columns.Clear();
        listView1.Columns.Add("No", 50, HorizontalAlignment.Left);
        listView1.Columns.Add("id", 0, HorizontalAlignment.Left);
        listView1.Columns.Add("user_id", 0, HorizontalAlignment.Left);
        listView1.Columns.Add("name", 0, HorizontalAlignment.Left);
        DataTable dat = new coursemuid().selecttablecourse("*", whereclause);
     listView1.Items.Clear();
     int counter = 1;
     foreach (DataRow row in dat.Rows)
      {
     ListViewItem lv = new ListViewItem(counter.ToString());
     lv.SubItems.Add(row[0].ToString());
     lv.SubItems.Add(row[1].ToString());
     lv.SubItems.Add(row[2].ToString());
     counter++;
     listView1.Items.Add(lv);
     }
 }
Exemplo n.º 2
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     coursemuid mymodel= new coursemuid();
      if (myflag < 1)
     {
      if(mymodel.validate_int(textBoxid.Text)==true&&mymodel.validate_int(textBoxuser_id.Text)==true){
        mymodel.insertcourse("id,user_id,name",Convert.ToInt32(textBoxid.Text)+","+Convert.ToInt32(textBoxuser_id.Text)+","+"'"+Convert.ToString(textBoxname.Text)+"'");
      }
      else{
      MessageBox.Show("Validation Failed!");
      }
     }
      else
     {
      if(mymodel.validate_int(textBoxid.Text)==true&&mymodel.validate_int(textBoxuser_id.Text)==true){
        mymodel.updatecourse("id,user_id,name",Convert.ToInt32(textBoxid.Text)+","+Convert.ToInt32(textBoxuser_id.Text)+","+"'"+Convert.ToString(textBoxname.Text)+"'","where id="+textBoxid.Text);
      }
      else{
      MessageBox.Show("Validation Failed!");
      }
     }
 }