Example #1
0
 public ActionResult Edit(int id)
 {
     Context.SalesOrder dbitem = RepoSalesOrder.FindByPK(id);
     if (dbitem.SalesOrderOncallId.HasValue)
     {
         SalesOrderOncall model = new SalesOrderOncall(dbitem);
         ViewBag.kondisi        = "planning";
         ViewBag.name           = model.SONumber;
         ViewBag.area           = RepoSalesOrder.FindArea(dbitem.SalesOrderOncall.IdDaftarHargaItem.Value);
         ViewBag.is_area_pulang = RepoSalesOrder.FindRute(dbitem.SalesOrderOncall.IdDaftarHargaItem.Value).IsAreaPulang == true ? "Yes" : "No";
         ViewBag.TanggalPulang  = model.TanggalMuat.Value.AddDays(RepoSalesOrder.FindRute(dbitem.SalesOrderOncall.IdDaftarHargaItem.Value).WaktuKerja);
         ViewBag.Title          = "Planning Sales Order Oncall " + model.SONumber;
         ViewBag.PostData       = "EditOncall";
         return(View("SalesOrderOncall/FormReadOnly", model));
     }
     else if (dbitem.SalesOrderProsesKonsolidasiId.HasValue)
     {
         SalesOrderProsesKonsolidasi model = new SalesOrderProsesKonsolidasi(dbitem);
         ViewBag.kondisi  = "planning";
         ViewBag.name     = model.SONumber;
         ViewBag.Title    = "Planning Sales Order Proses Konsolidasi " + model.SONumber;
         ViewBag.PostData = "EditProsesKonsolidasi";
         return(View("SalesOrderProsesKonsolidasi/FormReadOnly", model));
     }
     else if (dbitem.SalesOrderPickupId.HasValue)
     {
         SalesOrderPickup model = new SalesOrderPickup(dbitem);
         ViewBag.kondisi  = "planning";
         ViewBag.name     = model.SONumber;
         ViewBag.Title    = "Planning Sales Order Pickup " + model.SONumber;
         ViewBag.PostData = "EditPickup";
         return(View("SalesOrderPickup/FormReadOnly", model));
     }
     else
     {
         return(View(""));
     }
 }
Example #2
0
        public ActionResult Edit(int id, string caller)
        {
            Context.Dokumen dbitem        = RepoDokumen.FindByPK(id);
            List <int>      ListIdDokumen = dbitem.DokumenItem.Select(b => b.IdBilling).ToList();
            string          strQuery      = "";

            //cek apakah di billing customer ada penambahan data
            //jika ada maka update data jika data dokumen belum close
            if (!dbitem.IsComplete)
            {
                Context.Customer dbcust = dbitem.Customer;
                foreach (var itemBilling in dbitem.Customer.CustomerBilling.Where(i => !ListIdDokumen.Contains(i.Id)).ToList())
                {
                    dbitem.DokumenItem.Add(new Context.DokumenItem()
                    {
                        IdBilling    = itemBilling.Id,
                        CustomerId   = itemBilling.CustomerId,
                        ModifiedDate = DateTime.Now,
                    });
                    strQuery += "INSERT INTO dbo.\"DokumenItem\" (\"IdBilling\", \"CustomerId\", \"ModifiedDate\") VALUES (" + itemBilling.Id + ", " + itemBilling.CustomerId + ", " + DateTime.Now + ");";
                }
                RepoDokumen.save(dbitem, UserPrincipal.id, strQuery);
            }

            if (dbitem.SalesOrder.SalesOrderOncallId.HasValue)
            {
                ViewBag.TanggalPulang = dbitem.SalesOrder.SalesOrderOncall.TanggalMuat.Value.AddDays(RepoSalesOrder.FindRute(dbitem.SalesOrder.SalesOrderOncall.IdDaftarHargaItem.Value).WaktuKerja);
            }
            Dokumen model = new Dokumen(dbitem);

            ViewBag.caller = caller;
            if (caller == "admin")
            {
                ViewBag.Title = "Dokumen Admin Surat Jalan";
            }
            else
            {
                ViewBag.Title = "Dokumen Billing";
            }

            return(View("Form", model));
        }