Exemplo n.º 1
0
 public bool SPPForm(SppDashboard model)
 {
     try
     {
         SppDashboard sd = db.sppData.Find(model.spp_id);
         if (sd == null)
         {
             if (model.spp_number == null)
             {
                 model.spp_number = "Belum ada No SPP";
             }
             model.spp_date   = DateTime.Now;
             model.created_at = DateTime.Now;
             model.updated_at = DateTime.Now;
             db.sppData.Add(model);
             db.SaveChanges();
         }
         else
         {
             model.updated_at = DateTime.Now;
             db.Entry(sd).CurrentValues.SetValues(model);
             db.Entry(sd).State = EntityState.Modified;
             db.SaveChanges();
         }
         TempData["tempModel"] = model;
         return(true);
     }
     catch (Exception e)
     {
         Log.Error(e);
         return(false);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Menghapus SPP
 /// </summary>
 /// <param name="po">Kode PO</param>
 /// <param name="id">ID SPP</param>
 /// <returns></returns>
 public ActionResult SPPDelete(string po, int?id)
 {
     if (id > 0)
     {
         try
         {
             SppDashboard sd = db.sppData.Find(id);
             db.sppData.Remove(sd);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             Log.Error(e);
             throw;
         }
     }
     return(RedirectToAction("SPPBoard", new { po = po }));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Simpan model ke SPP dengan PO yang ada di multiple PO
 /// </summary>
 /// <param name="model"></param>
 private void SavePo(MultiplePrint model)
 {
     try
     {
         foreach (string item in model.multiple_po)
         {
             string[]     splitString = item.Split(' ');
             string       getPo       = splitString[0];
             int          getSppId    = Int32.Parse(splitString[3]);
             SppDashboard sd          = db.sppData.FirstOrDefault(f => f.spp_id == getSppId);
             if (sd != null)
             {
                 //SppDashboard nsd = new SppDashboard();
                 sd.spp_number            = model.spp_number;
                 sd.spp_date              = model.spp_date;
                 sd.address               = model.address;
                 sd.npwp                  = model.npwp;
                 sd.bank_name             = model.bank_name;
                 sd.bill_number           = model.bill_number;
                 sd.bill_owner            = model.bill_owner;
                 sd.kabag_from            = model.kabag_from;
                 sd.kabag_from_name       = model.kabag_from_name;
                 sd.kabag_from_nik        = model.kabag_from_nik;
                 sd.kabag_accounting_name = model.kabag_accounting_name;
                 sd.updated_at            = DateTime.Now;
                 //db.Entry(sd).CurrentValues.SetValues(nsd);
                 db.Entry(sd).State = EntityState.Modified;
             }
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
 }
Exemplo n.º 4
0
        public ActionResult SPPForm(string po, int?spp)
        {
            try
            {
                ViewBag.useAjax       = true;
                ViewBag.useDatePicker = true;
                ViewBag.useIcheck     = true;
                ViewBag.po            = po;
                ViewBag.supplier      = "";
                ViewBag.address       = "";
                ViewBag.npwp          = "";
                ViewBag.billNumber    = "";
                ViewBag.cur           = "";
                if (po != null && po != "")
                {
                    PoTransactions pt = new PoTransactions(po);
                    //var poOptions = db.sppData.Select(s => s.po).ToList();
                    generatePaymentDropDown(false);
                    SppDashboard model        = new SppDashboard();
                    string       supplier     = pt.getSupplier();
                    string[]     supplierInfo = pt.getSupplierInfo();
                    if (supplier != null)
                    {
                        ViewBag.supplier = supplier;
                    }
                    model.spp_date = DateTime.Now;
                    var cur = db.dbPoProduct.FirstOrDefault(f => f.po == po);
                    if (cur != null)
                    {
                        try
                        {
                            ViewBag.cur = cur.cur;
                        }
                        catch (ArgumentNullException)
                        {
                            ViewBag.cur = "0";
                        }
                    }

                    List <string> poOptions = pt.getMultiplePo(ViewBag.supplier);
                    ViewBag.options = poOptions;

                    if (spp > 0)
                    {
                        model = pt.getSpp(spp);
                        if (model != null)
                        {
                            if (model.spp_date == null || model.spp_date == DateTime.MinValue)
                            {
                                model.spp_date = DateTime.Now;
                            }
                            if (supplierInfo != null && supplierInfo.Count() > 0)
                            {
                                model.address     = model.address != null ? model.address : supplierInfo[1];
                                model.npwp        = model.npwp != null ? model.npwp : supplierInfo[2];
                                model.bill_number = model.bill_number != null ? model.bill_number : supplierInfo[3];
                            }
                            ViewBag.attachmentOptions = model.attachment;

                            JavaScriptSerializer js       = new JavaScriptSerializer();
                            InvoiceFormat[]      invoices = js.Deserialize <InvoiceFormat[]>(model.invoice_number);
                            if (invoices.Count() > 0)
                            {
                                foreach (var invoice in invoices)
                                {
                                    model.invoice_num   = invoice.number;
                                    model.invoice_date  = invoice.date;
                                    model.invoice_value = invoice.total;
                                }
                            }

                            return(View(model));
                        }
                        ViewBag.noData = true;
                        return(View());
                    }
                    else
                    {
                        if (supplierInfo != null && supplierInfo.Count() > 0)
                        {
                            model.address     = model.address != null ? model.address : supplierInfo[1];
                            model.npwp        = model.npwp != null ? model.npwp : supplierInfo[2];
                            model.bill_number = model.bill_number != null ? model.bill_number : supplierInfo[3];
                        }
                    }
                    return(View(model));
                }
                ViewBag.noData = true;
                return(View());
            }
            catch (Exception e)
            {
                Log.Error(e);
                ViewBag.useAjax       = true;
                ViewBag.useDatePicker = true;
                ViewBag.useIcheck     = true;
                ViewBag.po            = po;
                ViewBag.cur           = "";
                ViewBag.supplier      = "";
                ViewBag.address       = "";
                ViewBag.npwp          = "";
                ViewBag.billNumber    = "";
                ViewBag.noData        = true;
                return(View());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Print SPP
        /// </summary>
        /// <returns>SPP Print model</returns>
        public ActionResult PrintSPP()
        {
            try
            {
                PrintSPPNew ps = new PrintSPPNew();
                if (TempData[TRANSFER_MODEL] != null)
                {
                    SppDashboard sppd = TempData[TRANSFER_MODEL] as SppDashboard;
                    ps.address         = sppd.address;
                    ps.another         = sppd.another;
                    ps.attachment      = sppd.attachment;
                    ps.bank_name       = sppd.bank_name;
                    ps.bill_number     = sppd.bill_number;
                    ps.bill_owner      = sppd.bill_owner;
                    ps.document_number = sppd.document_number;

                    ps.invoice_number = sppd.invoice_number;

                    JavaScriptSerializer js       = new JavaScriptSerializer();
                    InvoiceFormat[]      invoices = js.Deserialize <InvoiceFormat[]>(ps.invoice_number);
                    if (invoices.Count() > 0)
                    {
                        foreach (var invoice in invoices)
                        {
                            ps.invoice_num   = invoice.number;
                            ps.invoice_date  = DateTime.ParseExact(invoice.date, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                            ps.invoice_value = invoice.total;

                            ViewBag.intWord = ps.invoice_value.ToText();
                        }
                    }

                    //ps.note = sppd.note;
                    ps.npwp        = sppd.npwp;
                    ps.payment_for = sppd.payment_for;
                    ps.po          = sppd.po;
                    //ps.spp_date = sppd.spp_date;
                    ps.spp_number            = sppd.spp_number;
                    ps.kabag_from            = sppd.kabag_from;
                    ps.kabag_from_name       = sppd.kabag_from_name;
                    ps.kabag_from_nik        = sppd.kabag_from_nik;
                    ps.kabag_accounting_name = sppd.kabag_accounting_name;

                    var getDpb =
                        from basis in db.dbSpph
                        join dpb in db.dbDpb on basis.dpb equals dpb.dpb
                        where basis.po == ps.po
                        select new { jobcode = dpb.job_code, jobcodet = dpb.job_code_t };
                    var firstData = getDpb.FirstOrDefault();
                    ps.job_code_x = firstData.jobcode + " - " + firstData.jobcodet;

                    ps.supplier = sppd.supplier;
                }
                return(View(ps));
            }
            catch (Exception e)
            {
                Log.Error(e);
                PrintSPPNew ps = new PrintSPPNew();
                return(View(ps));
            }
        }