public ActionResult NewCash([FromBody] Cash[] cashes) { string result = "Sistem xətası"; if (_context.Cash.Where(d => d.Defenition == cashes[0].Defenition && d.Number == cashes[0].Number).Count() > 0) { return(Json("Bu məlumatlara uyğun kassa mövcuddur")); } try { Cash cash = new Cash(); cash.Number = cashes[0].Number; cash.Defenition = cashes[0].Defenition; _context.Add(cash); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewDuration([FromBody] PaymentDuration[] paymentDurations) { string result = "Sistem xətası"; if (_context.PaymentDuration.Where(n => n.ContractDetailId == paymentDurations[0].ContractDetailId).ToList().Count != 0) { result = "Bu gecikmə üzrə qeyd mövcuddur"; return(Json(result)); } try { PaymentDuration paymentDuration = new PaymentDuration(); paymentDuration.ContractDetailId = paymentDurations[0].ContractDetailId; paymentDuration.PaymentDate = paymentDurations[0].PaymentDate; paymentDuration.Reason = paymentDurations[0].Reason; paymentDuration.CreateDate = DateTime.Now; _context.Add(paymentDuration); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı"; return(Json(result)); } catch (SqlException ex) { result = ex.Message; return(Json(result)); } }
public async Task <IActionResult> PaymentCreate([Bind("Id,Amount,Explanation,TransactionTypeId,SignTypeId,CashId,CostTypeId,ContractDetailId")] Payments payments) { try { if (ModelState.IsValid) { payments.SignTypeId = 1; payments.TransactionTypeId = 1; _context.Add(payments); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(PaymentDetail)); return(RedirectToAction("PaymentDetail", "Payments", new { Id = payments.Id })); } ViewData["CashId"] = new SelectList(_context.Cash, "Id", "Id", payments.CashId); ViewData["ContractDetailId"] = new SelectList(_context.ContractDetail, "Id", "Id", payments.ContractDetailId); ViewData["SignTypeId"] = new SelectList(_context.SignType, "Id", "Id", payments.SignTypeId); ViewData["TransactionTypeId"] = new SelectList(_context.TransactionType, "Id", "Id", payments.TransactionTypeId); //return View(payments); } catch (Exception ex) { } return(View(payments)); }
public ActionResult NewCustomer([FromBody] Customers[] customers) { if (_context.Customers.Where( c => c.Name == customers[0].Name && c.Surname == customers[0].Surname && c.DocNumber == customers[0].DocNumber && c.Phone == customers[0].Phone).Count() > 0) { return(Json("Bu müştəri artıq mövcuddur")); } string result = "Sistem xətası"; try { Customers customer = new Customers(); customer.Name = customers[0].Name; customer.Surname = customers[0].Surname; customer.Phone = customers[0].Phone; customer.Email = customers[0].Email; customer.DocNumber = customers[0].DocNumber; customer.CustomerTypeId = customers[0].CustomerTypeId; _context.Add(customer); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewObject([FromBody] Objects[] objects) { if (_context.Objects.Where( o => o.BuildingId == objects[0].BuildingId && o.Floor == objects[0].Floor && o.Porch == objects[0].Porch && o.Number == objects[0].Number && o.ObjectTypeId == objects[0].ObjectTypeId).Count() > 0) { return(Json("Bu obyek artıq mövcuddur")); } string result = ""; try { Objects obj = new Objects(); obj.Porch = objects[0].Porch; obj.Floor = objects[0].Floor; obj.Number = objects[0].Number; obj.Squares = objects[0].Squares; obj.BuildingId = objects[0].BuildingId; obj.ObjectTypeId = objects[0].ObjectTypeId; _context.Add(obj); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewBuilding([FromBody] Building[] buildings) { string result = "Sistem xətası"; if (_context.Building.Where(n => n.Number == buildings[0].Number && n.Address == buildings[0].Address).Count() > 0) { return(Json("Bu məlumatlara uyğun bina mövcuddur")); } try { Building building = new Building(); building.Number = buildings[0].Number; building.Address = buildings[0].Address; _context.Add(building); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public async Task <IActionResult> Create([Bind("Id,ContractDetailId,SupportTypeId,ObjectsId,Amount,SpDefenition,ObjNumber,CustomersId,MonthDept")] PaymentsList paymentsList) { if (ModelState.IsValid) { _context.Add(paymentsList); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(paymentsList)); }
public ActionResult NewSupportType([FromBody] SupportType[] supportTypes) { string result = "Sistem xətası"; try { SupportType supportType = new SupportType(); supportType.Defenition = supportTypes[0].Defenition; _context.Add(supportType); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public async Task <IActionResult> Create([Bind("Id,Amount,CreatedDate,PaymentDate,Explanation,Explanation2,Explanation3,ContractId,Customer,Cash,CostTypDefenition,IncomeTypeDefenition,TransactionTypDefenition,SupportTypDefenition,Number,CustDocno,SignTypeId,SignTypeDefenition,CashId,TransactionTypeId,CustomersId,CostTypeId,SupportTypeId,ObjectsId,PaymentsId,IncomeTypeId")] PaymentTransactions paymentTransactions) { if (ModelState.IsValid) { _context.Add(paymentTransactions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(paymentTransactions)); }
public async Task <IActionResult> Create([Bind("Id,Defenition,Number")] Permission permission) { if (ModelState.IsValid) { _context.Add(permission); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(permission)); }
public async Task <IActionResult> Create([Bind("Id,Name,Surname,Explanation")] Salary salary) { if (ModelState.IsValid) { _context.Add(salary); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(salary)); }
public async Task <IActionResult> Create([Bind("Id,Defenition")] SignType signType) { if (ModelState.IsValid) { _context.Add(signType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(signType)); }
public async Task <IActionResult> Create([Bind("Id,Amount,CashId,Number,Defenition")] CashBalance cashBalance) { if (ModelState.IsValid) { _context.Add(cashBalance); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cashBalance)); }
public ActionResult AddContractDetail([FromBody] ContractDetail[] contractDetails) { string result = ""; try { ContractDetail contractDetail = new ContractDetail(); contractDetail.ContractId = contractDetails[0].ContractId; contractDetail.SupportTypeId = contractDetails[0].SupportTypeId; contractDetail.ObjectsId = contractDetails[0].ObjectsId; contractDetail.ServicePrice = contractDetails[0].ServicePrice; _context.Add(contractDetail); _context.SaveChanges(); } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public async Task <IActionResult> Create([Bind("Id,ContractDetailId,PaymentDate,Reason,CreateDate")] PaymentDuration paymentDuration) { if (ModelState.IsValid) { _context.Add(paymentDuration); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContractDetailId"] = new SelectList(_context.ContractDetail, "Id", "Id", paymentDuration.ContractDetailId); return(View(paymentDuration)); }
public async Task <IActionResult> Create([Bind("Id,UserId,PermissionId,Acces")] UserPermissions userPermissions) { if (ModelState.IsValid) { _context.Add(userPermissions); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["PermissionId"] = new SelectList(_context.Permission, "Id", "Id", userPermissions.PermissionId); ViewData["UserId"] = new SelectList(_context.Set <Users>(), "Id", "Password", userPermissions.UserId); return(View(userPermissions)); }
public ActionResult NewIncomeType([FromBody] IncomeType[] incomeTypes) { if (_context.IncomeType.Where(i => i.Defenition == incomeTypes[0].Defenition).Count() > 0) { return(Json("Bu mədaxil növü mövcuddur")); } string result = "Sistem xətası"; try { IncomeType incomeType = new IncomeType(); incomeType.Defenition = incomeTypes[0].Defenition; _context.Add(incomeType); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public async Task <IActionResult> Create([Bind("Id,ContractId,SupportTypeId,ServicePrice,ObjectsId")] ContractDetail contractDetail) { if (ModelState.IsValid) { _context.Add(contractDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ContractId"] = new SelectList(_context.Contract, "Id", "Id", contractDetail.ContractId); ViewData["ObjectsId"] = new SelectList(_context.Set <Objects>(), "Id", "Floor", contractDetail.ObjectsId); ViewData["SupportTypeId"] = new SelectList(_context.Set <SupportType>(), "Id", "Defenition", contractDetail.SupportTypeId); return(View(contractDetail)); }
public ActionResult NewObjectType([FromBody] ObjectType[] objectTypes) { if (_context.ObjectType.Where(o => o.Defenition == objectTypes[0].Defenition).Count() > 0) { return(Json("Bu obyekt növü mövcuddur")); } string result = "Sistem xətası"; try { ObjectType objectType = new ObjectType(); objectType.Defenition = objectTypes[0].Defenition; _context.Add(objectType); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewCustomerType([FromBody] CustomerType[] customerTypes) { if (_context.CustomerType.Where(d => d.Defenition == customerTypes[0].Defenition).Count() > 0) { return(Json("Bu müştəri tipi mövcuddur")); } string result = "Sistem xətası"; try { CustomerType customerType = new CustomerType(); customerType.Defenition = customerTypes[0].Defenition; _context.Add(customerType); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewCostType([FromBody] CostType[] costTypes) { if (_context.CostType.Where(c => c.Defenition == costTypes[0].Defenition).Count() > 0) { return(Json("Bu məxaric növü mövcuddur")); } string result = "Sistem xətası"; try { CostType costType = new CostType(); costType.Defenition = costTypes[0].Defenition; _context.Add(costType); _context.SaveChanges(); result = "Əməliyyat uğurla tamamlandı!"; } catch (Exception ex) { result = ex.Message; } return(Json(result)); }
public ActionResult NewUser([FromBody] Users[] users) { string result = "Sistem xətası"; if (_context.Users.Where(n => n.Username == users[0].Username).Count() > 0) { result = "Daxil etdiyiniz istifadəçi adı artıq mövcuddur"; return(Json(result)); } else { try { Users user = new Users(); user.Username = users[0].Username; user.Password = Encrypt(users[0].Password.ToString()); user.IsAdmin = users[0].IsAdmin; _context.Add(user); _context.SaveChanges(); var query = "select * from permission"; //var connectionString = "Server=Namik;Database=AMSDBSECOND;Trusted_Connection=true;MultipleActiveResultSets=true"; DataTable dt; SqlConnection con = new SqlConnection(CheckPermission.GetConnection()); SqlCommand cmd = new SqlCommand(query, con); con.Open(); var a = cmd.ExecuteReader(); dt = new DataTable(); dt.Load(a); con.Close(); SqlCommand cmd2 = new SqlCommand(query, con); for (int i = 0; i < dt.Rows.Count; i++) { var c = dt.Rows[i]["Id"]; } SqlTransaction transaction = null; var connection = new SqlConnection(CheckPermission.GetConnection()); connection.Open(); transaction = connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted, "Excell import"); var command = connection.CreateCommand(); command.CommandTimeout = 0; command.Transaction = transaction; for (int i = 0; i < dt.Rows.Count; i++) { command.CommandText += $@"insert into UserPermissions(UserId,PermissionId,Acces) values ({user.Id},{dt.Rows[i]["Id"]},0)"; } command.ExecuteNonQuery(); transaction.Commit(); result = "Əməliyyat uğurla tamamlandı"; return(Json(result)); } catch (Exception ex) { result = ex.Message; return(Json(result)); } } }