Exemple #1
0
        public IActionResult Post([FromBody] Payment payment)
        {
            if (payment == null)
            {
                return(BadRequest());
            }

            _context.Payments.Add(payment);
            _context.SaveChanges();
            return(Ok(_context));
        }
Exemple #2
0
 /// <summary>
 /// 不良品电池从包中移除
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public static Result NgBatteryOutFromPack(string code)
 {
     using (var db = new Data.AppContext())
     {
         try
         {
             var battery = db.Batteries.Where(o => o.Code == code).OrderByDescending(o => o.Id).FirstOrDefault();
             if (battery == null)
             {
                 return(new Result("系统中不存在电池:" + code));
             }
             if (battery.PackStatus == PackStatus.良品)
             {
                 return(new Result("该电池已经被移除"));
             }
             battery.PackStatus = PackStatus.良品;
             battery.PackId     = 0;
             if (db.SaveChanges() > 0)
             {
                 Arthur.App.Business.Logging.AddOplog("不良品电池从包中移除" + code, OpType.编辑);
             }
             return(Result.Success);
         }
         catch (Exception ex)
         {
             return(new Result(ex));
         }
     }
 }
Exemple #3
0
 public Result AddTaskLog()
 {
     try
     {
         using (var db = new Data.AppContext())
         {
             db.TaskLogs.Add(new TaskLog()
             {
                 ProcTrayId = Current.Task.ProcTrayId,
                 EndTime    = DateTime.Now,
                 StartTime  = Current.Task.StartTime,
                 StorageId  = Current.Task.StorageId,
                 TaskType   = Current.Task.Type,
                 UserId     = Current.User.Id,
                 Time       = DateTime.Now
             });
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(new Result(ex));
     }
     return(Result.Success);
 }
Exemple #4
0
        public Result Create(Pack pack)
        {
            try
            {
                var id = -1;
                using (var db = new Data.AppContext())
                {
                    var _pack = db.Packs.FirstOrDefault(o => o.Code == pack.Code);
                    if (_pack == null)
                    {
                        _pack = db.Packs.Add(new Pack()
                        {
                            Code       = pack.Code,
                            Model      = Current.Option.ProductModel,
                            ScanTime   = DateTime.Now,
                            SortResult = pack.SortResult
                        });
                        db.SaveChanges();
                    }
                    id = _pack.Id;
                }

                Arthur.App.Business.Logging.AddOplog(string.Format("新增箱体[{0}]", pack.Code), Arthur.App.Model.OpType.创建);

                return(Result.SuccessHasData(id));
            }
            catch (Exception ex)
            {
                return(new Result(ex));
            }
        }
Exemple #5
0
        private void delete_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var id      = Convert.ToInt32((sender as TextBlock).Tag);
            var taskLog = _AppContext.TaskLogs.SingleOrDefault(r => r.Id == id);

            if (taskLog == null)
            {
                MessageBox.Show("不存在该任务,删除失败!", "异常提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (Current.User.Role.Level < _ArthurContext.Roles.Single(r => r.Name == "管理员").Level)
            {
                MessageBox.Show("当前用户权限不足!", "异常提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            if (MessageBox.Show(string.Format("确定要删除该任务日志吗?", ""), "删除确认", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                _AppContext.TaskLogs.Remove(taskLog);
                _AppContext.SaveChanges();
                Arthur.App.Business.Logging.AddOplog(string.Format("删除任务日志[ID:{0}]", taskLog.Id), Arthur.App.Model.OpType.除);
                UpdateDataGrid(PageIndex);
            }
        }
        public void InsertUpdatePortal()
        {
            var portal = _context.Portals.ToList();

            portal[0].Url        = "https://www.rightmove.co.uk";
            portal[0].OutCodeKey = "OUTCODE%5E";

            _context.Portals.Update(portal[0]);
            _context.SaveChanges();
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="procTray"></param>
        /// <param name="isScan">扫码获得,不是手动添加的</param>
        /// <returns></returns>
        public Result Create(ProcTray procTray, bool isScan)
        {
            try
            {
                var id = -1;

                using (var db = new Data.AppContext())
                {
                    var tray = db.Trays.FirstOrDefault(t => t.Code == procTray.Code);
                    if (tray == null)
                    {
                        tray = db.Trays.Add(new Tray()
                        {
                            Code       = procTray.Code,
                            CreateTime = DateTime.Now,
                            Company    = "SZYitong",
                            IsEnabled  = true,
                            Name       = procTray.Code,
                        });
                    }

                    var proctray = db.ProcTrays.Add(new ProcTray()
                    {
                        TrayId         = tray.Id,
                        StorageId      = -1,
                        Code           = procTray.Code,
                        ScanTime       = DateTime.Now,
                        StartStillTime = DateTime.Now,//Arthur.Default.DateTime
                        Model          = Current.Option.ProductModel
                    });

                    db.SaveChanges();

                    id = proctray.Id;
                }

                if (isScan)
                {
                    LogHelper.WriteInfo("绑盘托盘扫码:" + procTray.Code);
                }
                else
                {
                    Arthur.App.Business.Logging.AddOplog(string.Format("新增流程托盘[{0}]", procTray.Code), Arthur.App.Model.OpType.创建);
                }
                return(Result.SuccessHasData(id));
            }
            catch (Exception ex)
            {
                return(new Result(ex));
            }
        }
Exemple #8
0
 public static Result SetPackFinish(int packId)
 {
     using (var db = new Data.AppContext())
     {
         try
         {
             db.Batteries.Where(o => o.PackId == packId).ToList().ForEach(o => o.PackStatus = PackStatus.打包完);
             db.SaveChanges();
             return(Result.Success);
         }
         catch (Exception ex)
         {
             return(new Result(ex));
         }
     }
 }
Exemple #9
0
 public static Result SetPacking(int id, int packId)
 {
     using (var db = new Data.AppContext())
     {
         try
         {
             var battery = db.Batteries.FirstOrDefault(o => o.Id == id);
             battery.PackId     = packId;
             battery.PackStatus = PackStatus.打包中;
             db.SaveChanges();
             return(Result.Success);
         }
         catch (Exception ex)
         {
             return(new Result(ex));
         }
     }
 }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="battery"></param>
        /// <param name="isScan">扫码获得,不是手动添加的</param>
        /// <returns></returns>
        public Result Create(Battery battery, bool isScan)
        {
            try
            {
                //if (Context.Batteries.Count(r => r.Code == battery.Code) > 0)
                //{
                //    return new Result(string.Format("系统中已存在条码为{0}的电池!", battery.Code));
                //}
                using (var db = new Data.AppContext())
                {
                    db.Batteries.Add(new Battery()
                    {
                        Code       = battery.Code,
                        ScanTime   = DateTime.Now,
                        ProcTrayId = Current.Option.Tray11_Id,
                        Pos        = ProcTrayManage.GetBatteryCount(Current.Option.Tray11_Id) + 1,
                        SortResult = SortResult.Unknown,
                        Model      = Current.Option.ProductModel,
                        IsUploaded = false,
                        PackId     = -1,
                        PackStatus = PackStatus.未打包,
                        CAP        = 0,
                        ESR        = 0,
                        TestTime   = DateTime.Now
                    });
                    db.SaveChanges();
                }

                if (isScan)
                {
                    LogHelper.WriteInfo("电池扫码:" + battery.Code);
                }
                else
                {
                    Arthur.App.Business.Logging.AddOplog(string.Format("新增电池[{0}]", battery.Code), Arthur.App.Model.OpType.创建);
                }
                return(Result.Success);
            }
            catch (Exception ex)
            {
                return(new Result(ex));
            }
        }
Exemple #11
0
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            var company = this.company.Text.Trim();

            try
            {
                this.Tray.Company = company;
                _AppContext.SaveChanges();

                tip.Background = new SolidColorBrush(Colors.Green);
                tip.Text       = "修改信息成功!";
            }
            catch (Exception ex)
            {
                tip.Background = new SolidColorBrush(Colors.Red);
                tip.Text       = "修改信息失败:" + ex.Message;
            }

            tip.Visibility = Visibility.Visible;
        }
Exemple #12
0
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            var trays = _AppContext.Trays.ToList();

            var code       = this.code.Text.Trim();
            var pos        = this.pos.Text.Trim();
            var procTrayId = -1;

            if (this.proctray.SelectedIndex > 0)
            {
                var tray      = trays[this.proctray.SelectedIndex - 1];
                var proc_tray = _AppContext.ProcTrays.Where(o => o.TrayId == tray.Id).OrderByDescending(o => o.Id).FirstOrDefault() ?? new Model.ProcTray();
                procTrayId = proc_tray.Id;
            }

            tip.Background = new SolidColorBrush(Colors.Red);

            if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(pos))
            {
                tip.Text = "请填写数据!";
            }
            else
            {
                try
                {
                    this.Battery.Code       = code;
                    this.Battery.ProcTrayId = procTrayId;
                    this.Battery.Pos        = Convert.ToInt32(pos);

                    _AppContext.SaveChanges();
                    tip.Background = new SolidColorBrush(Colors.Green);
                    tip.Text       = "修改信息成功!";
                }
                catch (Exception ex)
                {
                    tip.Text = "修改信息失败:" + ex.Message;
                }
            }
            tip.Visibility = Visibility.Visible;
        }
Exemple #13
0
        public static Result Upload(Battery battery)
        {
            Result result;

            using (var db = new GMCCContext())
            {
                var sql = string.Format("INSERT INTO AutoSorting (CaseNumber, BarCode, CAP, ESR, TestDate, UserID, UserName) VALUES ('{0}', '{1}', {2}, {3}, '{4}', {5}, '{6}')",
                                        GetObject.GetById <Pack>(battery.PackId).Code, battery.Code, battery.CAP, battery.ESR, battery.TestTime, Current.User.Id, Current.User.Name);
                try
                {
                    if (db.Database.ExecuteSqlCommand(sql) > 0)
                    {
                        result = Result.Success;
                    }
                    else
                    {
                        return(new Result(""));
                    }
                }
                catch (Exception ex)
                {
                    return(new Result(ex));
                }
            }

            using (var db = new Data.AppContext())
            {
                try
                {
                    battery            = db.Batteries.Where(o => o.Id == battery.Id).FirstOrDefault();
                    battery.IsUploaded = true;
                    db.SaveChanges();
                    return(Result.Success);
                }
                catch (Exception ex)
                {
                    return(new Result(ex));
                }
            }
        }
Exemple #14
0
 public Result Create(Tray tray)
 {
     try
     {
         using (var db = new Data.AppContext())
         {
             if (db.Trays.Count(r => r.Code == tray.Code) > 0)
             {
                 return(new Result(string.Format("系统中已存在条码为{0}的托盘!", tray.Code)));
             }
             db.Trays.Add(new Tray()
             {
                 Code = tray.Code, Company = tray.Company, CreateTime = DateTime.Now, IsEnabled = true
             });
             db.SaveChanges();
         }
         Arthur.App.Business.Logging.AddOplog(string.Format("新增托盘[{0}]", tray.Code), Arthur.App.Model.OpType.创建);
         return(Result.Success);
     }
     catch (Exception ex)
     {
         return(new Result(ex.Message));
     }
 }
Exemple #15
0
 public void Save()
 {
     _db.SaveChanges();
 }
Exemple #16
0
        public async Task <IActionResult> DodajKnjigu(KnjigeDodajVM model)
        {
            if (model.PdfByte == null && model.Mp3Byte == null)
            {
                ModelState.AddModelError("PdfByte", "PDF ili mp3 fajl su obavezni");
            }

            if (model.TipoviId != null)
            {
                var tipovi   = _db.TipFajlova;
                var pdfTipId = tipovi.SingleOrDefault(x => x.Naziv == "PDF").TipFajlaID;
                var mp3TipId = tipovi.SingleOrDefault(x => x.Naziv == "MP3").TipFajlaID;

                if (model.PdfByte == null && model.TipoviId.Contains(pdfTipId))
                {
                    ModelState.AddModelError("PdfByte", "PDF fajl je obavezan");
                }

                if (model.Mp3Byte == null && model.TipoviId.Contains(mp3TipId))
                {
                    ModelState.AddModelError("Mp3Byte", "MP3 fajl je obavezan");
                }

                if (model.PdfByte != null && !model.TipoviId.Contains(pdfTipId))
                {
                    ModelState.AddModelError("PdfByte", "Niste odabrali tip fajla PDF za uneseni PDF dokument");
                }

                if (model.Mp3Byte != null && !model.TipoviId.Contains(mp3TipId))
                {
                    ModelState.AddModelError("Mp3Byte", "Niste odabrali tip fajla MP3 za uneseni MP3 fajl");
                }
            }

            if (!ModelState.IsValid)
            {
                model.Autori = _db.Autori.Select(k => new SelectListItem
                {
                    Value = k.AutorID.ToString(),
                    Text  = k.Ime + " " + k.Prezime
                }).ToList();

                model.Tipovi = _db.TipFajlova.Select(t => new SelectListItem
                {
                    Value = t.TipFajlaID.ToString(),
                    Text  = t.Naziv
                }).ToList();

                model.Kategorije = _db.Kategorije.Select(k => new SelectListItem
                {
                    Value = k.KategorijaID.ToString(),
                    Text  = k.Naziv
                }).ToList();

                Response.StatusCode = 400;
                return(PartialView(model));
            }

            EKnjiga knjiga = new EKnjiga
            {
                Naziv           = model.Naziv,
                AdministratorID = HttpContext.getKorisnickiNalogAdministrator().AdministratorID,
                Cijena          = model.Cijena,
                Opis            = model.Opis
            };

            if (model.SlikaByte != null)
            {
                knjiga.Slika = await _fileManager.Save(model.SlikaByte, "/Slike", $"{knjiga.Naziv}-{Guid.NewGuid()}.png");
            }

            if (model.PdfByte != null)
            {
                knjiga.PdfPath = await _fileManager.Save(model.PdfByte, "/PdfFajlovi", $"{knjiga.Naziv}-{Guid.NewGuid()}.pdf");
            }

            if (model.Mp3Byte != null)
            {
                knjiga.Mp3Path = await _fileManager.Save(model.Mp3Byte, "/Mp3Fajlovi", $"{knjiga.Naziv}-{Guid.NewGuid()}.mp3");
            }

            _db.EKnjige.Add(knjiga);
            _db.SaveChanges();

            foreach (var autorID in model.AutoriID)
            {
                var autor = new EKnjigeAutor
                {
                    AutorID   = autorID,
                    EKnjigaID = knjiga.EKnjigaID
                };
                _db.EKnjigaAutori.Add(autor);
            }

            foreach (var tipFajlaId in model.TipoviId)
            {
                var tipFajla = new EKnjigaTip
                {
                    TipFajlaID = tipFajlaId,
                    EKnjigaID  = knjiga.EKnjigaID
                };
                _db.EKnjigaTipovi.Add(tipFajla);
            }

            foreach (var kategorijaID in model.KategorijeID)
            {
                var kategorija = new EKnjigaKategorija
                {
                    KategorijaID = kategorijaID,
                    EKnjigaID    = knjiga.EKnjigaID
                };
                _db.EKnjigaKategorije.Add(kategorija);
            }

            _db.SaveChanges();
            return(Ok());
        }
Exemple #17
0
 private int SaveChanges()
 {
     return(_contexto.SaveChanges());
 }
Exemple #18
0
 public void Delete(Guid id)
 {
     _appContext.Processors.Remove(_appContext.Processors.Find(id));
     _appContext.SaveChanges();
 }