//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); }
//insert selected values to Login_Table during registration public static regValidation insertLogin(regValidation C) { try { Login_Table l = new Login_Table(); l.User_ID = C.CustomeriD; l.Password = C.Password; l.UserType = "Customer"; T.Login_Table.Add(l); T.SaveChanges(); return(C); } catch (DbUpdateException E) { SqlException ex = E.GetBaseException() as SqlException; } return(null); }