Ejemplo n.º 1
0
        public ActionResult Water_usageAdd(Water_usage item)
        {
            var data = Context.Water_usage.Find(item.customer_services_id);
            int water_usagefirst;

            bill_Water_usage[] bill = Context.bill_Water_usage.Where(x => x.Water_usage.customer_services_id == data.customer_services_id).OrderByDescending(x => x.Water_usage.Createinvoiceperiods.date).ToArray();
            Water_usage[]      cus  = Context.Water_usage.Where(x => x.Uid == item.customer_services_id).ToArray();
            if (bill.Count() == 0)
            {
                water_usagefirst = cus[0].customer_services.meter_First_unit.Value;
            }
            else
            {
                water_usagefirst = bill[0].water_usageafter;
            }
            Session["invoiceperiods_id"] = data.invoiceperiods_id;
            ViewBag.time = Session["invoiceperiods_id"];
            if (item.water_Unit > water_usagefirst)
            {
                data.invoiceperiods_id = new Guid(Session["invoiceperiods_id"].ToString());
                data.water_Unit        = item.water_Unit;
                Context.SaveChanges();
                if (DAL.DALWater_usage.GetWater_usage_inid(data.invoiceperiods_id) == 0)
                {
                    var i = Context.Createinvoiceperiods.Find(data.invoiceperiods_id);
                    i.status = Statusinvoiceperiods.ready;
                    Context.SaveChanges();
                    DALbill_Water.bill_Water_Add(data.invoiceperiods_id);
                }
                return(View(DAL.DALWater_usage.GetWater_usage()));
            }
            ViewBag.error = "หน่วยที่ใช้ไม่ถูกต้อง หน่วยเดือนก่อนหน้า : " + water_usagefirst;

            return(View(DAL.DALWater_usage.GetWater_usage()));
        }
Ejemplo n.º 2
0
 public IActionResult Create(AssetDetails assetDetails)
 {
     if (ModelState.IsValid)
     {
         _db.Add(assetDetails);
         _db.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(assetDetails));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "ID,Name,Type,AskingRent")] Asset asset)
        {
            if (ModelState.IsValid)
            {
                db.Assets.Add(asset);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(asset));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "Id,Name,ShortName,Code")] AssetType assetType)
        {
            if (ModelState.IsValid)
            {
                db.AssetTypes.Add(assetType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assetType));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "Id,AssetEntryId,Notes")] Note note)
        {
            if (ModelState.IsValid)
            {
                db.Notes.Add(note);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", note.AssetEntryId);
            return(View(note));
        }
        public ActionResult Create([Bind(Include = "Id,AssetTypeId,Name,ShortName,GroupCode")] AssetGroup assetGroup)
        {
            if (ModelState.IsValid)
            {
                db.AssetGroups.Add(assetGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetTypeId = new SelectList(db.AssetTypes, "Id", "Name", assetGroup.AssetTypeId);
            return(View(assetGroup));
        }
        public ActionResult Create([Bind(Include = "Id,AssetEntryId,File")] Attchment attchment)
        {
            if (ModelState.IsValid)
            {
                db.Attchments.Add(attchment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", attchment.AssetEntryId);
            return(View(attchment));
        }
        public ActionResult Create([Bind(Include = "Id,AssetEntryId,Description,ServiceDate,ServiceingCostDecimal,PartsCostDecimal,TaxDecimal,ServiceBy")] ServiceOrRepairing serviceOrRepairing)
        {
            if (ModelState.IsValid)
            {
                db.ServiceOrRepairings.Add(serviceOrRepairing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", serviceOrRepairing.AssetEntryId);
            return(View(serviceOrRepairing));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Id,AssetEntryId,VendorId,ParchasePrice,ParchaseOrderNo,PurchaseDate")] Finance finance)
        {
            if (ModelState.IsValid)
            {
                db.Finances.Add(finance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetEntryId = new SelectList(db.AssetEntries, "Id", "AssetId", finance.AssetEntryId);
            ViewBag.VendorId     = new SelectList(db.Vendors, "Id", "VendorName", finance.VendorId);
            return(View(finance));
        }
        public ActionResult Create([Bind(Include = "Id,AssetGroupId,AssetManufacurerId,Name,ShortName,Code,Description")] AssetModel assetModel)
        {
            if (ModelState.IsValid)
            {
                db.AssetModels.Add(assetModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetGroupId       = new SelectList(db.AssetGroups, "Id", "Name", assetModel.AssetGroupId);
            ViewBag.AssetManufacurerId = new SelectList(db.AssetManufacurers, "Id", "Name", assetModel.AssetManufacurerId);
            return(View(assetModel));
        }
Ejemplo n.º 11
0
        internal bool Add(Vendor vendor)
        {
            _context.Vendors.Add(vendor);
            var row = _context.SaveChanges();

            return(row > 0);
        }
Ejemplo n.º 12
0
        public bool Add(PurchaseOrder purchaseOrder)
        {
            _context.PurchaseOrders.Add(purchaseOrder);
            var row = _context.SaveChanges();

            return(row > 0);
        }
Ejemplo n.º 13
0
        internal bool Add(GeneralCategory generalCategory)
        {
            _context.GeneralCategories.Add(generalCategory);
            var rowAffected = _context.SaveChanges();

            return(rowAffected > 0);
        }
Ejemplo n.º 14
0
        public bool Add(Category category)
        {
            _context.Categories.Add(category);
            var rowAffected = _context.SaveChanges();

            return(rowAffected > 0);
        }
        public static void Insertinvoiceperiods(Createinvoiceperiods item)
        {
            if (item != null)
            {
                item.Uid    = Guid.NewGuid();
                item.num    = Context.customer_services.Where(x => x.status == customer_services.Status.ready).Count();
                item.status = Createinvoiceperiods.Statusinvoiceperiods.Wait;
                Context.Createinvoiceperiods.Add(item);
                Context.SaveChanges();

                foreach (var i in Context.customer_services.Where(x => x.status == customer_services.Status.ready))
                {
                    AssetDbContext add  = new AssetDbContext();
                    var            data = new waterwork.Models.Water_usage()
                    {
                        Uid = Guid.NewGuid(),
                        invoiceperiods_id    = item.Uid,
                        customer_services_id = i.Uid,
                        water_Unit           = 0
                    };
                    add.Water_usage.Add(data);
                    add.SaveChanges();
                }
                ;
            }
        }
Ejemplo n.º 16
0
        internal bool Add(Product product)
        {
            _context.Products.Add(product);
            var rowAffected = _context.SaveChanges();

            return(rowAffected > 0);
        }
        public bool Add(SubCategory subcategory)
        {
            _context.SubCategories.Add(subcategory);

            var rowAffected = _context.SaveChanges();

            return(rowAffected > 0);
        }
        public ActionResult Create([Bind(Include = "Id,OrganizationId,BranchId,AssetLocationId,AssetTypeId,AssetGroupId,AssetManufacurerId,AssetModelId,AssetId,Name,SerialNo,Status,Attachment")] AssetEntry assetEntry)
        {
            if (ModelState.IsValid)
            {
                _db.AssetEntries.Add(assetEntry);
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AssetGroupId       = new SelectList(_db.AssetGroups, "Id", "Name", assetEntry.AssetGroupId);
            ViewBag.AssetLocationId    = new SelectList(_db.AssetLocations, "Id", "Name", assetEntry.AssetLocationId);
            ViewBag.AssetManufacurerId = new SelectList(_db.AssetManufacurers, "Id", "Name", assetEntry.AssetManufacurerId);
            ViewBag.AssetModelId       = new SelectList(_db.AssetModels, "Id", "Name", assetEntry.AssetModelId);
            ViewBag.AssetTypeId        = new SelectList(_db.AssetTypes, "Id", "Name", assetEntry.AssetTypeId);
            ViewBag.BranchId           = new SelectList(_db.Branches, "Id", "Name", assetEntry.BranchId);
            ViewBag.OrganizationId     = new SelectList(_db.Organizations, "Id", "Name", assetEntry.OrganizationId);
            return(View(assetEntry));
        }
Ejemplo n.º 19
0
        public ActionResult Water_usageAdd(Water_usage item)
        {
            AssetDbContext Context = new AssetDbContext();
            var            data    = Context.Water_usage.Find(item.customer_services_id);

            data.invoiceperiods_id = new Guid(Session["invoiceperiods_id"].ToString());
            data.water_Unit        = item.water_Unit;
            Context.SaveChanges();
            Session["invoiceperiods_id"] = data.invoiceperiods_id;
            ViewBag.time = Session["invoiceperiods_id"];
            if (DAL.DALWater_usage.GetWater_usage_inid(data.invoiceperiods_id) == 0)
            {
                var i = Context.Createinvoiceperiods.Find(data.invoiceperiods_id);
                i.status = Statusinvoiceperiods.ready;
                Context.SaveChanges();
                DALbill_Water.bill_Water_Add(data.invoiceperiods_id);
            }
            return(View(DAL.DALWater_usage.GetWater_usage()));
        }
Ejemplo n.º 20
0
        public static void Insertcustomer_services(customer_services item)
        {
            AssetDbContext Context = new AssetDbContext();

            if (item != null)
            {
                item.Uid = Guid.NewGuid();
                Context.customer_services.Add(item);
                Context.SaveChanges();
            }
        }
 public void Save()
 {
     try
     {
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 22
0
        public ActionResult Misterupdate(MVCxGridViewBatchUpdateValues <customer_services, int> updateValues)
        {
            AssetDbContext context = new AssetDbContext();

            foreach (var Item in updateValues.Update)
            {
                var data = context.customer_services.Find(Item.Uid);
                data.status           = customer_services.Status.ready;
                data.meter_id         = Item.meter_id;
                data.meter_First_unit = Item.meter_First_unit;
                context.SaveChanges();
            }
            return(PartialView("MisterDataEditPartialView", waterwork.DAL.DALcustomer_services.Getcustomer_services_Wait()));
        }
Ejemplo n.º 23
0
        public static void bill_Water_Add(Guid id)
        {
            var Water_use = Context.Water_usage.Where(x => x.invoiceperiods_id == id).ToList();

            foreach (var i in Water_use)
            {
                var data = new bill_Water_usage
                {
                    Uid              = Guid.NewGuid(),
                    Water_usage_id   = i.Uid,
                    water_usagefirst = water_usagefirst(i.customer_services_id),
                    water_usageafter = i.water_Unit,
                    unit             = i.water_Unit - water_usagefirst(i.customer_services_id),
                    service_charge   = 5,
                    Minimum_rate     = Minimum_rate(i.water_Unit - water_usagefirst(i.customer_services_id)),
                    price            = ((i.water_Unit - water_usagefirst(i.customer_services_id)) * 7) + 5 + Minimum_rate(i.water_Unit - water_usagefirst(i.customer_services_id)),
                    status           = bill_Water_usage.Statusbill.Wait
                };
                Context.bill_Water_usage.Add(data);
                Context.SaveChanges();
            }
        }
Ejemplo n.º 24
0
        public static void bill_Water_Add(Guid id)
        {
            AssetDbContext Context   = new AssetDbContext();
            var            Water_use = Context.Water_usage.Where(x => x.invoiceperiods_id == id).ToList();

            foreach (var i in Water_use)
            {
                var data = new bill_Water_usage
                {
                    Uid              = Guid.NewGuid(),
                    Water_usage_id   = i.Uid,
                    water_usagefirst = 0,
                    water_usageafter = i.water_Unit,
                    unit             = 0 - i.water_Unit,
                    service_charge   = 15,
                    Minimum_rate     = 35,
                    price            = (0 - i.water_Unit) * 5,
                    status           = bill_Water_usage.Statusbill.Wait
                };
                Context.bill_Water_usage.Add(data);
                Context.SaveChanges();
            }
        }
 public int Complete()
 {
     return(_context.SaveChanges());
 }