public static bool insertUser(UserDetail obj, bool isInsert) { bool status = false; if (obj != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); if (isInsert) { //Case of Insert obj.CreatedOn = DateTime.Now; dc.UserDetails.InsertOnSubmit(obj); } else { //Case of update UserDetail dbobj = dc.UserDetails.Where(x => x.UserID == obj.UserID).SingleOrDefault(); if (dbobj != null) { dbobj.FullName = obj.FullName; dbobj.UserName = obj.UserName; dbobj.PasswordAsHash = obj.PasswordAsHash; dbobj.UserType_ID = obj.UserType_ID; } } dc.SubmitChanges(); status = true; } //Status represents if Insert/Object became successful or not return(status); }
public static bool insertCustomer(Customer cust, bool isInsert) { bool status = false; if (cust != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); if (isInsert) { cust.CreatedOn = DateTime.Now; dc.Customers.InsertOnSubmit(cust); } else { Customer dbCust = dc.Customers.Where(x => x.CustomerID == cust.CustomerID).SingleOrDefault(); if (dbCust != null) { dbCust.Name = cust.Name; dbCust.Address = cust.Address; dbCust.ModifiedOn = DateTime.Now; } } dc.SubmitChanges(); status = true; } return(status); }
public static bool insertItem(ItemOrProduct itm, bool isInsert) { bool status = false; if (itm != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); if (isInsert) { itm.CreatedOn = DateTime.Now; dc.ItemOrProducts.InsertOnSubmit(itm); } else { ItemOrProduct dbItem = dc.ItemOrProducts.Where(x => x.ItemID == itm.ItemID).SingleOrDefault(); dbItem.Name = itm.Name; dbItem.PurchasePrice = itm.PurchasePrice; dbItem.SalesPrice = itm.SalesPrice; dbItem.OpeningQty = itm.OpeningQty; dbItem.InStock = itm.InStock; } dc.SubmitChanges(); status = true; } return(status); }
public static bool insertUserType(tblUserType userType, bool isInsert) { bool status = false; if (userType != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); if (isInsert) { //Case of Inserting a new UserType dc.tblUserTypes.InsertOnSubmit(userType); } else { //Case of Updating a new UserType tblUserType dbUserType = dc.tblUserTypes.Where(x => x.UserTypeID == userType.UserTypeID).SingleOrDefault(); dbUserType.Name = userType.Name; } dc.SubmitChanges(); status = true; } return(status); }
public static bool deleteItem(ItemOrProduct Itm) { bool status = false; if (Itm != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); ItemOrProduct dbItem = dc.ItemOrProducts.Where(x => x.ItemID == Itm.ItemID).SingleOrDefault(); dc.ItemOrProducts.DeleteOnSubmit(dbItem); dc.SubmitChanges(); status = true; } return(status); }
public static bool deleteCustomer(Customer cust) { bool status = false; if (cust != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); Customer dbcust = dc.Customers.Where(x => x.CustomerID == cust.CustomerID).SingleOrDefault(); if (dbcust != null) { dc.Customers.DeleteOnSubmit(dbcust); dc.SubmitChanges(); status = true; } } return(status); }
public static bool deleteUser(UserDetail obj) { bool status = false; if (obj != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); UserDetail dbObj = dc.UserDetails.Where(x => x.UserID == obj.UserID).SingleOrDefault(); if (dbObj != null) { dc.UserDetails.DeleteOnSubmit(dbObj); dc.SubmitChanges(); status = true; } } return(status); }
public static bool deleteUserType(tblUserType userType) { bool status = false; if (userType != null) { SampleDatabaseDataContext dc = new SampleDatabaseDataContext(); tblUserType dbobj = dc.tblUserTypes.Where(x => x.UserTypeID == userType.UserTypeID).SingleOrDefault(); if (dbobj != null) { dc.tblUserTypes.DeleteOnSubmit(dbobj); dc.SubmitChanges(); status = true; } } return(status); }