public async Task <ActionResult> EditAccountant(Accountants model, List <IFormFile> files) { if (ModelState.IsValid) { try { await _accountant.Edit(model, files); TempData["success"] = "Accountant Info Edited Successfully"; return(RedirectToAction("EditAccountant")); } catch (DbUpdateConcurrencyException) { if (!AccountantExists(model.Id)) { return(NotFound()); } else { throw; } } } TempData["error"] = "Unable to edit Accountant Info"; return(View(model)); }
public async Task <string> Create(AccountantDto model) { //var officer = _httpContextAccessor.HttpContext.User.Identity.Name; //if (officer == "SuperAdmin") //{ // officer = "Admin"; //} var user = new ApplicationUser { UserName = model.Email, SurName = model.SurName, Email = model.Email, FirstName = model.FirstName, OtherName = model.OtherName, MobileNo = model.MobileNo, Sex = model.Sex, Address = model.Address, EntityStatus = model.Status }; var result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { await userManager.AddToRoleAsync(user, "Accountant"); Accountants accountant = new Accountants(); accountant.UserId = user.Id; accountant.SurName = model.SurName; accountant.FirstName = model.SurName; accountant.OtherName = model.OtherName; accountant.EmailAddress = model.Email; accountant.PhoneNo = model.PhoneNo; accountant.MobileNo = model.MobileNo; accountant.Sex = model.Sex; accountant.Address = model.Address; accountant.Status = model.Status; accountant.ProfilePicture = model.ProfilePicture; _context.Accountants.Add(accountant); await _context.SaveChangesAsync(); //var acctReg = await _context.Accountants.FirstOrDefaultAsync(x => x.UserId == user.Id); //string numberid = acctReg.Id.ToString("D3"); //acctReg.AccountantReg = "ACCT/" + numberid; //_context.Entry(acctReg).State = EntityState.Modified; //await _context.SaveChangesAsync(); return("true"); } var errors = result.Errors; var message = string.Join(",", errors); return(message); }
public async Task Edit(Accountants model, List <IFormFile> files) { if (files.Count == 0) { model.ProfilePicture = model.ProfilePicture; } else { var fileName = await _upload.UploadFile(files, _env); model.ProfilePicture = "/Uploads/" + fileName; } _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); }
private void ExcuteDbGridSelectChange() { ButtonMDEna = (ViewInvoice != null && ViewInvoice.InvoiceNumber != null) ? true : false; if (ViewInvoice != null && ViewInvoice.InvoiceNumber != null) { int DepId; using (var db = new DataModel()) { DepId = db.Persons.Where(p => p.PersonId == ViewInvoice.PersonId).FirstOrDefault().DepId; } // 选择切换后部门、当前报销人、财务的切换 Department = Departments.Where(d => d.DepartmentId == DepId).FirstOrDefault(); Person = Persons.Where(p => p.PersonId == ViewInvoice.PersonId).FirstOrDefault(); Accountant = Accountants.Where(o => o.AccountantId == ViewInvoice.AcctId).FirstOrDefault(); TempViewInvoice = (InputInvoice)CloneObject(ViewInvoice); } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real" ////} InitlGroupRadio(); ButtonEna = true; ButtonEnaN = !ButtonEna; QueryDateEna = true; State = "查询"; //DetailEna=false; pageDateQuery = new DateQuery(); pageOperatorQuery = new OperatorQuery(); pagePeopleQuery = new PeopleQuery(); pageSnQuery = new SnQuery(); string year = DateTime.Now.Year.ToString() + "0101"; FromDate = DateTime.ParseExact(year, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); ToDate = DateTime.Now.AddDays(1); Page = pageDateQuery; QueryInvoices = new List <Invoice>(); viewInvoices = new ObservableCollection <InputInvoice>(); QueryInvoice = new Invoice(); ViewInvoice = new InputInvoice(); TempViewInvoice = new InputInvoice();//显示detail的控件用这个值 using (var db = new DataModel()) { //Operators = db.Operators.Include(p => p.Person).ToList(); Accountants = db.Accountants.ToList(); Departments = db.Departments.ToList(); Persons = db.Persons.ToList(); //Persons = db.Persons.Where(p => p.DepId == 3).ToList(); } Accountant = Accountants.Where(a => a.AccountantId == Information.AccountantId).FirstOrDefault(); int i = Accountants.Count; ExcuteQueryCommand(); }