Exemplo n.º 1
0
 public bool UpdateCustomer(int custID, string custName, string custSSN,
                            string custEmail, string custPhone)
 {
     using (ist420grp5Entities1 entities = new ist420grp5Entities1())
     {
         //Update a Record
         //Create the custent cust object
         tblCustomerBrianTran cust = new tblCustomerBrianTran();
         cust = entities.tblCustomerBrianTrans.Find(custID);
         cust.CustomerName = (custName == null) ? cust.CustomerName :
                             custName;
         cust.CustomerSSN = (custSSN == null) ? cust.CustomerSSN :
                            custSSN;
         cust.CustomerEmail = (custEmail == null) ? cust.CustomerEmail :
                              custEmail;
         cust.CustomerPhone = (custPhone == null) ? cust.CustomerPhone :
                              custPhone;
         //Save the changes to the DB
         entities.SaveChanges();
         //cust.fldStudentID will contain the record number
         if (cust.CustomerID > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemplo n.º 2
0
 public string CreateCustomer(string custName, string custSSN, string
                              custEmail, string custPhone)
 {
     using (ist420grp5Entities1 entities = new ist420grp5Entities1())
     {
         //Insert a Record
         //Create the custent cust obect
         tblCustomerBrianTran cust = new tblCustomerBrianTran();
         cust.CustomerName  = custName;
         cust.CustomerSSN   = custSSN;
         cust.CustomerEmail = custEmail;
         cust.CustomerPhone = custPhone;
         //Call the method to add the object to the table
         entities.tblCustomerBrianTrans.Add(cust);
         //Save the changes to the DB
         entities.SaveChanges();
         //cust.CustomerID will contain the record number
         if (cust.CustomerID > 0)
         {
             return(cust.CustomerID.ToString());
         }
         else
         {
             return("false");
         }
     }
 }
Exemplo n.º 3
0
 public tblCustomerBrianTran ReadCustomer(int custID)
 {
     using (ist420grp5Entities1 entities = new ist420grp5Entities1())
     {
         tblCustomerBrianTran cust = new tblCustomerBrianTran();
         cust = entities.tblCustomerBrianTrans.Find(custID);
         return(cust);
     }
 }
Exemplo n.º 4
0
 public bool DeleteCustomer(int custID)
 {
     using (ist420grp5Entities1 entities = new ist420grp5Entities1())
     {
         //Create the custent cust object
         tblCustomerBrianTran cust = new tblCustomerBrianTran();
         try
         {
             cust = entities.tblCustomerBrianTrans.Find(custID);
             //Delete a record
             entities.tblCustomerBrianTrans.Remove(cust);
             entities.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 } //End DeleteStudent