public static bool Insert(People objPeople)
 {
     SqlCeConnection con = new SqlCeConnection(@"Data Source=C:\Users\ManojKumar\Documents\GitHub\ContactsExample\ContactsADO\bin\Debug\ContactsDB.sdf;Persist Security Info=False;");
     SqlCeCommand com = new SqlCeCommand();
     try
     {
         con.Open();
         com.Connection = con;
         com.CommandText = @"INSERT INTO People(Name, Company, Telephone, Email, Client, LastCall) "+
             @"VALUES(@Name, @Company, @Telephone, @Email, @Client, @LastCall)";
         com.Parameters.Add(new SqlCeParameter("Name", objPeople.Name));
         com.Parameters.Add(new SqlCeParameter("Company", objPeople.Company));
         com.Parameters.Add(new SqlCeParameter("Telephone", objPeople.Telephone));
         com.Parameters.Add(new SqlCeParameter("Email", objPeople.Email));
         com.Parameters.Add(new SqlCeParameter("Client", objPeople.Client));
         com.Parameters.Add(new SqlCeParameter("LastCall", objPeople.LastCall));
         com.ExecuteNonQuery();
     }
     catch (Exception e)
     {
     }
     finally
     {
         con.Close();
     }
     return true;
 }
示例#2
0
 private void btnInsert_Click(object sender, EventArgs e)
 {
     People objPeople = new People();
     objPeople.Client = cbxClient.Checked;
     objPeople.Company = txtCompany.Text;
     objPeople.Email = txtEmail.Text;
     objPeople.LastCall = dtLastCall.Value;
     objPeople.Name = txtName.Text;
     objPeople.Telephone = txtTelephone.Text;
     PeopleUIController.Insert(objPeople);
 }
 public static bool Insert(People objPeople)
 {
     return PeopleServiceLayer.Insert(objPeople);
 }