Beispiel #1
0
        private static void RunAsUpdater(string[] args)
        {
            if (args.Length < 3 || args[0] != "AU")             //check for correct call (AU PID EXEPATH)
            {
                return;
            }

            if (!IsRunAsAdmin())
            {
                System.Windows.Forms.MessageBox.Show(Strings.BoxAutoUpdateRequireAdmin, Strings.BoxAutoUpdateResult, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            GitHub.CleanupOldVersion();

            int    PID           = int.Parse(args[1]);
            string lasergrblpath = args[2];

            try
            {
                System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(PID);
                if (P != null && !P.WaitForExit(1000))                 //wait for process exit
                {
                    P.Kill();
                }
            }
            catch { }


            try
            {
                foreach (System.Diagnostics.Process Pn in System.Diagnostics.Process.GetProcessesByName("LaserGRBL")) //if other instance - kill them!
                {
                    if (Pn.Id != System.Diagnostics.Process.GetCurrentProcess().Id)                                   //do not kill myself!!
                    {
                        try { Pn.Kill(); }
                        catch { }
                    }
                }
            }
            catch { }

            if (GitHub.ApplyUpdateS2())             //at this moment LaserGRBL is not running!
            {
                System.Windows.Forms.MessageBox.Show(Strings.BoxAutoUpdateSuccess, Strings.BoxAutoUpdateResult, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(Strings.BoxAutoUpdateFailed, Strings.BoxAutoUpdateResult, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }

            if (System.IO.File.Exists(lasergrblpath))
            {
                System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo {
                    UseShellExecute = true, WorkingDirectory = Environment.CurrentDirectory, FileName = lasergrblpath
                };
                try { System.Diagnostics.Process.Start(p); }
                catch { }
            }
        }
Beispiel #2
0
        public ActionResult CreateCtPn(Pn item, IEnumerable <Ctpn> lst)
        {
            try
            {
                SanPham sp;
                foreach (var x in lst)
                { // cap nhap so luong
                    sp = SanPhamMager.GetSanPhamByID(x.MaSp);
                    if (PhieuNhapMager.ktthamso(x.MaSp, x.SoLuong) == true)
                    {
                        sp.SoLuongTon = sp.SoLuongTon + x.SoLuong;
                        SanPhamMager.uppdateSanPham(sp);
                        x.MaPN  = item.MaPN;
                        x.TenSP = sp.TenSp;
                    }

                    else
                    {
                        return(PartialView("error"));
                        //return Content("<script>  alert(\"" + x.SanPham.TenSp + " da bi loi \")+  location.reload(); </script>");
                    }
                }
                CtPnMager.insertall(lst);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("error"));
            }
        }
Beispiel #3
0
        public virtual bool MathPn(string pn)
        {
            if (String.IsNullOrWhiteSpace(Pn) || String.IsNullOrWhiteSpace(pn))
            {
                return(false);
            }

            return(pn.Replace("PN", "").Replace("pn", "") == Pn.Replace("PN", "").Replace("pn", ""));
        }
Beispiel #4
0
        public ActionResult CreateCtPn(Pn item)
        {
            ViewBag.tennv = item.NhanVien.TenNv;
            ViewBag.mapn  = item.MaPN;
            List <SanPham> lstsp = SanPhamMager.getAllSanPham();

            ViewBag.sanpham = new SelectList(lstsp, "Masp", "TenSp");
            return(View());
        }
Beispiel #5
0
 private void Pnn(string v)
 {
     if (TR.InvokeRequired)
     {
         Pn C = new Pn(Pnn);
         this.Invoke(C, new object[] { v });
     }
     else
     {
         if (v == "")
         {
             TR.Text = "";
         }
         else
         {
             TR.Text = v;
         }
         TR.Refresh();
     }
 }
Beispiel #6
0
 public static Pn insert(Pn item)
 {
     return(new PnController().Insert(item));
 }
Beispiel #7
0
 public static Pn uppdate(Pn item)
 {
     return(new PnController().Update(item));
 }
Beispiel #8
0
 public ActionResult Create(Pn item)
 {
     PhieuNhapMager.insert(item);
     return(RedirectToAction("CreateCtPn", item));
 }