//gets the updated values and changes the value against current logged in user public static string updateCustomer(updateDetails C, int cid) { try { var c = from L in d.Customer_Table where L.Customer_ID == cid select L; Customer_Table CT = c.FirstOrDefault(); CT.Name = C.Name; CT.Address = C.Address; CT.City = C.City; CT.Country = C.Country; CT.State = C.State; CT.Pincode = int.Parse(C.Pincode); CT.Email = C.Email; CT.Contactno = C.Contact; CT.CustomerType = C.Ctype; d.SaveChanges(); return("Account Updated"); } catch (DbUpdateException E) { SqlException ex = E.GetBaseException() as SqlException; } return(null); }
//insert values to Customer_Table after generating customer ID public static regValidation insertCustomer(regValidation C) { try { Customer_Table C1 = new Customer_Table(); int r = (from c in T.Customer_Table select c).Count() + 1; DateTime dt = DateTime.Today; C.CustomeriD = dt.Year.ToString() + string.Format("{0:00}", dt.Month) + string.Format("{0:0000}", r); C1.Customer_ID = int.Parse(C.CustomeriD); C1.Name = C.Name; C1.Address = C.Address; C1.City = C.City; C1.State = C.State; C1.Country = C.Country; C1.Pincode = int.Parse(C.Pincode); C1.Email = C.Email; C1.Gender = C.Gender; C1.Contactno = C.Contact; C1.DateOfBirth = C.Dob; C1.CustomerType = C.Ctype; T.Customer_Table.Add(C1); T.SaveChanges(); return(C); } catch (DbUpdateException E) { SqlException ex = E.GetBaseException() as SqlException; } return(null); }