コード例 #1
0
 /// <summary>
 /// Update customer record in database.s
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btUpdateCust_Click(object sender, RoutedEventArgs e)
 {
     //label shows feedback of whether the record was updated successfully or not.
     lbUpdated.Content = Filler.WriteCust(@"update customer set"
                                          + @" [firstName] = @goGetFName, [LastName] = @goGetLName, "
                                          + @"[DoB] = @goGetDoB, [natins] = @goGetNat, [email] = @goGetEmail, "
                                          + @"[allowence] = @goGetAllowence WHERE [custID] = @goGetId;",
                                          new List <string> {
         "goGetFName", "goGetLName", "goGetDoB",
         "goGetNat", "goGetEmail", "goGetAllowence", "goGetId"
     },
                                          new List <object> {
         txtCustFName, txtCustLname, txtDob,
         txtNatins, txtEmail, txtAllowence, lbcustID
     }) ? "Success" : "Fail";
 }
コード例 #2
0
 /// <summary>
 /// Add new customer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btAddCustomer_Click(object sender, RoutedEventArgs e)
 {
     //validation check
     if (validate() == false)
     {
         return;
     }
     //add customer to data base, if this fails then don't clear text boxes — return/exit method.
     if (!filler.WriteCust(@"INSERT INTO customer ("
                           + @" title, [firstName], [LastName], DoB, natins, email, allowence) VALUES ( "
                           + @"@goGetTitle, @goGetFName, goGetLName, @goGetDoB, @goGetNat, @goGetEmail, "
                           + @" @goGetAllowence);",
                           new List <string> {
         "goGetTitle", "goGetFName", "goGetLName", "goGetDoB",
         "goGetNat", "goGetEmail", "goGetAllowence",
     },
                           new List <object> {
         txtCustTitle, txtCustFName, txtCustLName, txtCustDoB,
         txtCustNat, txtCustEmail, txtCustAllowence
     }))
     {
         return;
     }
     //clear text boxes
     txtCustTitle.Text     = "";
     txtCustFName.Text     = "";
     txtCustLName.Text     = "";
     txtCustDoB.Text       = "";
     txtCustEmail.Text     = "";
     txtCustNat.Text       = "";
     txtCustAllowence.Text = "";
     filler?.fillDataGrid("select * from customer;");
 }