public static bool InsertUserDetails(UserDetail obj, bool IsInsert)
        {
            bool status = false;

            if (obj != null)
            {
                DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
                if (IsInsert)
                {
                    obj.CreatedOn = DateTime.Now;
                    db.UserDetails.InsertOnSubmit(obj);
                }
                else
                {
                    UserDetail dbobj = db.UserDetails.Where(x => x.UserID == obj.UserID).SingleOrDefault();
                    if (dbobj != null)
                    {
                        dbobj.FullName       = obj.FullName;
                        dbobj.UserName       = obj.UserName;
                        dbobj.UserType       = obj.UserType;
                        dbobj.PasswordAsHash = obj.PasswordAsHash;
                    }
                }
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Example #2
0
        public static bool AddCustomer(Customer obj, bool isInsert)
        {
            bool status = false;

            if (obj != null)
            {
                DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
                if (isInsert)
                {
                    obj.CreatedOn = DateTime.Now;
                    db.Customers.InsertOnSubmit(obj);

                    status = true;
                }
                else
                {
                    Customer dbobj = db.Customers.Where(x => x.CustomerID == obj.CustomerID).SingleOrDefault();
                    if (dbobj != null)
                    {
                        dbobj.Name       = obj.Name;
                        dbobj.Address    = obj.Address;
                        dbobj.Gender     = obj.Gender;
                        dbobj.ModifiedOn = DateTime.Now;

                        status = true;
                    }
                }
                db.SubmitChanges();
            }
            return(status);
        }
Example #3
0
        public static void DeleteCustomerDetail(int customerId)
        {
            DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
            Customer obj = db.Customers.Where(x => x.CustomerID == customerId).SingleOrDefault();

            db.Customers.DeleteOnSubmit(obj);
            db.SubmitChanges();
        }
Example #4
0
        public static void DeleteItemDetails(Guid itemId)
        {
            DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
            ItemOrProduct obj = db.ItemOrProducts.Where(x => x.ItemID == itemId).SingleOrDefault();

            db.ItemOrProducts.DeleteOnSubmit(obj);
            db.SubmitChanges();
        }
        public static void DeleteUserTypeDetail(int usertypeId)
        {
            DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
            UserType obj = db.UserTypes.Where(x => x.UserTypeID == usertypeId).SingleOrDefault();

            db.UserTypes.DeleteOnSubmit(obj);
            db.SubmitChanges();
        }
Example #6
0
        public static bool AddItem(ItemOrProduct obj)
        {
            bool status = false;

            if (obj != null)
            {
                DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
                obj.CreatedOn = DateTime.Now;
                db.ItemOrProducts.InsertOnSubmit(obj);

                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Example #7
0
        public static bool EditItem(ItemOrProduct obj)
        {
            bool status = false;

            if (obj != null)
            {
                DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
                ItemOrProduct dbobj = db.ItemOrProducts.Where(x => x.ItemID == obj.ItemID).SingleOrDefault();

                if (dbobj != null)
                {
                    dbobj.Name          = obj.Name;
                    dbobj.PurchasePrice = obj.PurchasePrice;
                    dbobj.SalesPrice    = obj.SalesPrice;
                    dbobj.OpeningQty    = obj.OpeningQty;
                    dbobj.ModifiedOn    = DateTime.Now;
                }

                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
        public static bool InsertUserTypeDetails(UserType obj, bool IsInsert)
        {
            bool status = false;

            if (obj != null)
            {
                DataClassesSampleDatabaseDataContext db = new DataClassesSampleDatabaseDataContext();
                if (IsInsert)
                {
                    db.UserTypes.InsertOnSubmit(obj);
                }
                else
                {
                    UserType dbobj = db.UserTypes.Where(x => x.UserTypeID == obj.UserTypeID).SingleOrDefault();
                    if (dbobj != null)
                    {
                        dbobj.UserType1 = obj.UserType1;
                    }
                }
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }