public bool AddProduct(iproduct product)
        {
            var db = new dbsmappEntities();

            var prod = db.iproducts.FirstOrDefault(s => s.barcode.Equals(product.barcode));

            if (prod == null)
            {
                product.status = "activated";

                NullFiller.FillNullFields <iproduct>(product);

                Capitalize.UppercaseClassFields <iproduct>(product);

                db.iproducts.Add(product);

                var files = Request.Files;

                if (files.Count != 0)
                {
                    new ImageFunc().UploadProductPic(Request.Files, product.itemcode + "P");
                }

                db.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool AddProductPrice(iproductprice price)
        {
            var db = new dbsmappEntities();

            var pprice = db.iproductprices.FirstOrDefault(s => s.itemcode.Equals(price.itemcode));

            if (pprice == null)
            {
                price.status = "new";

                NullFiller.FillNullFields <iproductprice>(price);
                Capitalize.UppercaseClassFields <iproductprice>(price);

                db.iproductprices.Add(price);
            }
            else
            {
                pprice.sellingprice    = price.sellingprice;
                pprice.purchasingprice = price.purchasingprice;
                pprice.vatprice        = price.vatprice;
                pprice.remarks         = price.remarks;
            }

            db.SaveChanges();

            return(true);
        }
        public bool AddDepartment(sdepartment Department)
        {
            var db = new dbsmappEntities();

            var dept = db.sdepartments.FirstOrDefault(s => s.deptcode.Equals(Department.deptcode));

            if (dept == null)
            {
                Department.status = "activated";

                NullFiller.FillNullFields <sdepartment>(Department);
                Capitalize.UppercaseClassFields <sdepartment>(Department);

                db.sdepartments.Add(Department);
            }
            else
            {
                NullFiller.FillNullFields <sdepartment>(Department);
                Capitalize.UppercaseClassFields <sdepartment>(Department);

                dept.deptcode = Department.deptcode;
                dept.deptname = Department.deptname;
                dept.remarks  = Department.remarks;
                dept.status   = "ACTIVATED";
            }

            db.SaveChanges();

            return(true);
        }
Пример #4
0
        public bool AddBranch(xbranch branch)
        {
            var db = new dbsmappEntities();

            var brn = db.xbranches.FirstOrDefault(s => s.branchcode.Equals(branch.branchcode));

            if (brn == null)
            {
                NullFiller.FillNullFields <xbranch>(branch);
                Capitalize.UppercaseClassFields <xbranch>(branch);

                db.xbranches.Add(branch);
            }
            else
            {
                NullFiller.FillNullFields <xbranch>(branch);
                Capitalize.UppercaseClassFields <xbranch>(branch);

                brn.branchname = branch.branchname;
                brn.remarks    = branch.remarks;
            }

            db.SaveChanges();

            return(true);
        }
Пример #5
0
        public async Task <bool> UserSubmit(rUser model)
        {
            NullFiller.FillNullFields <rUser>(model);

            Capitalize.UppercaseClassFields <rUser>(model);

            var db = new dbsmappEntities();

            var isExist = db.userapps.FirstOrDefault(s => s.userid.Equals(model.userid));

            if (isExist != null)
            {
                return(false);
            }

            var emailAdd  = model.userid + "@danubeco.com";
            var newuserid = model.userid + "JED";

            var user = new User {
                UserName = newuserid, Email = emailAdd, Region = "JED"
            };

            //var rnpw = System.Web.Security.Membership.GeneratePassword(6, 0);

            var result = await UserManager.CreateAsync(user, "12345678");

            if (!result.Succeeded)
            {
                return(false);
            }

            var currentUser = await UserManager.FindByEmailAsync(emailAdd);

            await UserManager.AddToRolesAsync(currentUser.Id, model.role);

            db.userapps.Add(new userapp()
            {
                userid   = newuserid,
                empid    = model.userid,
                name     = model.name,
                role     = model.role,
                status   = "activated",
                login    = DateTime.Today,
                password = "******"
            });


            var files = Request.Files;

            if (files.Count != 0)
            {
                new ImageFunc().UploadProductPic(Request.Files, newuserid);
            }

            db.SaveChanges();

            return(true);
        }
        public async Task <bool> AddSupplier(rX supplier)
        {
            var db = new dnbmssqlEntities();

            NullFiller.FillNullFields <rX>(supplier);
            Capitalize.UppercaseClassFields <rX>(supplier);

            // Supplier Login
            var username = supplier.idd + supplier.region;

            var sup_user = db.C_User.FirstOrDefault(s => s.UserName.Equals(username));

            if (sup_user == null)
            {
                var user = new User {
                    UserName = username, Email = username + "@danubeco.com", Region = supplier.region
                };

                try
                {
                    var result = await UserManager.CreateAsync(user, supplier.password);

                    if (!result.Succeeded)
                    {
                        return(false);
                    }
                    else
                    {
                        SupplierInfo(supplier);

                        return(true);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                var user = await UserManager.FindByIdAsync(sup_user.UserId);

                user.PasswordHash = UserManager.PasswordHasher.HashPassword(supplier.password);

                await UserManager.UpdateAsync(user);

                SupplierInfo(supplier);

                return(true);
            }
        }
Пример #7
0
        public bool AddServices(nservice services)
        {
            var db = new dbsmappEntities();

            var serv = db.nservices.FirstOrDefault(s => s.servicescode.Equals(services.servicescode));

            if (serv == null)
            {
                NullFiller.FillNullFields <nservice>(services);
                Capitalize.UppercaseClassFields <nservice>(services);

                db.nservices.Add(services);
            }
            else
            {
                NullFiller.FillNullFields <nservice>(services);
                Capitalize.UppercaseClassFields <nservice>(services);

                serv.servicename     = services.servicename;
                serv.description     = services.description;
                serv.departmentid    = services.departmentid;
                serv.nprice          = services.nprice;
                serv.sprice          = services.sprice;
                serv.minutes         = services.minutes;
                serv.hours           = services.hours;
                serv.fixedcommission = services.fixedcommission;
                serv.remarks         = services.remarks;
                serv.status          = services.status;
            }


            var files = Request.Files;

            if (files.Count != 0)
            {
                new ImageFunc().UploadProductPic(Request.Files, services.servicescode + "S");
            }

            db.SaveChanges();

            return(true);
        }
        public bool UpdateProduct(iproduct product)
        {
            var db = new dbsmappEntities();

            var prod = db.iproducts.FirstOrDefault(s => s.itemcode.Equals(product.itemcode));

            if (prod == null)
            {
                return(false);
            }
            else
            {
                NullFiller.FillNullFields <iproduct>(product);

                Capitalize.UppercaseClassFields <iproduct>(product);

                prod.itemcode    = product.itemcode;
                prod.barcode     = product.barcode;
                prod.modelno     = product.modelno;
                prod.serialno    = product.serialno;
                prod.arname      = product.arname;
                prod.enname      = product.enname;
                prod.arshortname = product.arshortname;
                prod.enshortname = product.enshortname;
                prod.size        = product.size;
                prod.unit        = product.unit;
                prod.remarks     = product.remarks;
                prod.status      = product.status;

                var files = Request.Files;

                if (files.Count != 0)
                {
                    new ImageFunc().UploadProductPic(Request.Files, product.itemcode + "P");
                }

                db.SaveChanges();

                return(true);
            }
        }