コード例 #1
0
        public ActionResult POImport(PoImport model)
        {
            ViewBag.po          = model.po;
            ViewBag.addPoImport = false;

            if (User.IsInRole(PELAKSANA) || User.IsInRole(DEVELOPER))
            {
                ViewBag.useDatePicker = true;
                ViewBag.addPoImport   = true;
            }
            if (ModelState.IsValid)
            {
                try
                {
                    PoImport pi = db.poImportData.Find(model.po_import_id);
                    if (pi == null)
                    {
                        model.created_at = DateTime.Now;
                        model.updated_at = DateTime.Now;
                        db.poImportData.Add(model);
                        db.SaveChanges();
                    }
                    else
                    {
                        //pi = model;
                        model.updated_at = DateTime.Now;
                        db.Entry(pi).CurrentValues.SetValues(model);
                        db.Entry(pi).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    if (model.state == 0)
                    {
                        PoTransactions pt  = new PoTransactions(model.po);
                        var            ppp = pt.GetProducts();
                        if (ppp.Count() > 0)
                        {
                            ViewBag.cur = ppp.First().cur;
                        }
                        ViewBag.listProducts = ppp;
                        ViewBag.saved        = 1;
                        return(View(model));
                    }
                    else if (model.state == 1)
                    {
                        return(RedirectToAction("PrintPOImport", "Out", new { po = model.po }));
                    }
                    else if (model.state == 2)
                    {
                        return(RedirectToAction("PDFPoImport", "Out", new { po = model.po }));
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw;
                }
            }
            ViewBag.saved = 2;
            return(View(model));
        }
コード例 #2
0
        /// <summary>
        /// Print PO Impor
        /// </summary>
        /// <param name="po">Kode PO dalam bentuk string</param>
        /// <returns></returns>
        public ActionResult PrintPOImport(string po)
        {
            try
            {
                ViewBag.po = po;
                PoImport pi = db.poImportData.FirstOrDefault(p => p.po == po);
                if (pi != null)
                {
                    PrintPOImport ppi = new PrintPOImport()
                    {
                        po               = pi.po,
                        tanggal          = pi.tanggal,
                        ke               = pi.ke,
                        alamat           = pi.alamat,
                        no_telp          = pi.no_telp,
                        no_fax           = pi.no_fax,
                        attn             = pi.attn,
                        ref_po           = pi.ref_po,
                        condition        = pi.condition,
                        term_of_payment  = pi.term_of_payment,
                        pay_to_bank      = pi.pay_to_bank,
                        shipment         = pi.shipment,
                        delivery_time    = pi.delivery_time,
                        delivery_to      = pi.delivery_to,
                        attn_on_delivery = pi.attn_on_delivery,
                        manager          = pi.manager
                    };
                    PoTransactions pt  = new PoTransactions(po);
                    var            ppp = pt.GetProducts();
                    if (ppp.Count() > 0)
                    {
                        ViewBag.cur = ppp.First().cur;
                        float total = 0;
                        foreach (var item in ppp)
                        {
                            total += item.cur_amount;
                        }
                        ViewBag.total = total;
                    }

                    ViewBag.listProducts = ppp;
                    return(View(ppi));
                }
                ViewBag.noData = true;
                return(View());
            }
            catch (Exception e)
            {
                Log.Error(e);
                ViewBag.noData = true;
                return(View());
            }
        }
コード例 #3
0
 public bool POImportDelete(string po)
 {
     try
     {
         PoImport pi = db.poImportData.FirstOrDefault(p => p.po == po);
         if (pi != null)
         {
             db.poImportData.Remove(pi);
         }
         PoOption pop = db.poOptionData.FirstOrDefault(p => p.po == po);
         pop.po_import = false;
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Log.Error(e);
         return(false);
     }
 }