public DataVM SetFunctionPostDataItemIncremental([FromBody] DataVM data, [FromQuery] long incremental) { long value = long.Parse(data.Name); data.Name = (value + incremental).ToString(); return(data); }
private void btnOk_Click(object sender, EventArgs e) { if (id != -1) { using (var ctx = new UPdatabase()) { var result = ctx.UpData.SingleOrDefault(b => b.ID == id); result.UserName = txtName.Text; result.Password = Encryption.Encrypt(txtPassword.Text, true); ctx.SaveChanges(); } } else { var data = new DataVM(); data.UserName = txtName.Text; data.Password = Encryption.Encrypt(txtPassword.Text, true); using (var dbCtx = new UPdatabase()) { //Add Student object into Students DBset dbCtx.UpData.Add(data); // call SaveChanges method to save student into database dbCtx.SaveChanges(); } //MessageBox.Show("Data stored in the database"); } this.Close(); }
public DataVM GetFunctionPostDataItem() { DataVM data = new DataVM(); data.Name = "1"; return(data); }
/// <summary> /// constructor /// </summary> public MainWindow() { InitializeComponent(); VehicleSelectionVM = menu.VehicleSelectionVM; Data = new DataVM(VehicleSelectionVM); VehicleSelectionVM.VehicleVMs = Data.VehiclesVM.VehicleVMs; VehicleSelectionVM.RoutesVM = Data.RoutesVM; Content.DataContext = Data.RoutesVM; }
public override void Cleanup() { AlarmappVM.Cleanup(); DataVM.Cleanup(); RouteVM.Cleanup(); TimerVM.Cleanup(); VehiclesVM.Cleanup(); base.Cleanup(); }
public IActionResult Index() { DataVM dataVM = new DataVM { Data = _db.Data.FirstOrDefault(), Phone = _db.CenterPhoneNumbers.Where(p => p.DataId == _db.Data.FirstOrDefault().Id) }; return(View(dataVM)); }
private async Task RefreshListAsync() { IsRefreshing = true; await DataVM.RefreshAsync(); IsRefreshing = false; if (SelectedIndex == 1) { await SaveMainListDataAsync(); } }
public string Get(int id) { List <IViewModel> componentsToRender = new List <IViewModel>() { new CreditCardStatement(), new Account() }; DataVM data = new DataVM(componentsToRender, id); string data1 = JsonConvert.SerializeObject(data); return(data1); }
// GET: Students/Details/5 public async Task <IActionResult> Details(int?id) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } var student = await GetCurrentStudent(); if (student.IsAdmin) { if (id == null) { return(NotFound()); } var viewStudent = await _context.Students.FindAsync(id); if (viewStudent == null) { return(NotFound()); } var vm = new DataVM(); vm.CurrentStudent = viewStudent; vm.Enrollments = _context.Enrollments.Where(x => x.Student.StudentId == student.StudentId).ToList(); vm.Courses = new List <Course>(); foreach (var enrollment in vm.Enrollments) { vm.Courses.Add(_context.Courses.Where(x => x.CourseId == enrollment.CourseId).FirstOrDefault()); } return(View(vm)); } if (student == null) { return(RedirectToAction("Create")); } if (true) { var vm = new DataVM(); vm.CurrentStudent = student; vm.Enrollments = _context.Enrollments.Where(x => x.Student.StudentId == student.StudentId).ToList(); vm.Courses = new List <Course>(); foreach (var enrollment in vm.Enrollments) { vm.Courses.Add(_context.Courses.Where(x => x.CourseId == enrollment.CourseId).FirstOrDefault()); } return(View(vm)); } }
private void btnDelete_Click(object sender, EventArgs e) { UPdatabase ctx = new UPdatabase(); var item = new DataVM() { ID = id }; ctx.UpData.Attach(item); ctx.UpData.Remove(item); ctx.SaveChanges(); GetAllDbItems.RefreshGrid(grdData); }
/// <summary> /// constructor /// </summary> /// <param name="data">data view model</param> /// <param name="vehicleSelection">vehicle selection</param> public RoutesVM(DataVM data, VehicleSelection vehicleSelection) { this.data = data; VehicleSelection = vehicleSelection; foreach (var route in data.Data.Routes) { var routeVM = new RouteVM(route, data, vehicleSelection); RouteVMs.Add(routeVM); } RouteVMs.CollectionChanged += RouteVMs_CollectionChanged; }
private async Task RefreshListAsync() { IsRefreshing = true; await DataVM.RefreshAsync(); if (SelectedIndex == NEW_INDEX) { await InsertTodayWallpaperAsync(); } // Don't hide the refreshing hint too fast await Task.Delay(1000); IsRefreshing = false; }
private async Task RefreshListAsync() { IsRefreshing = true; await DataVM.RefreshAsync(); if (SelectedIndex == NEW_INDEX && AppSettings.Instance.EnableTodayRecommendation) { await InsertTodayWallpaperAsync(); } // Don't hide the refreshing hint too fast await Task.Delay(1000); IsRefreshing = false; }
public void SetHomePage() { Home = HomeVM.GetInstance(); MainData = DataVM.GetInstance(); Settings = SettingsVM.GetInstance(); CredentialForServerVM.GetInstance(); ChildrenAddVM.GetInstance(); MainData.backspaceButton += SetPreviousPage; Settings.backspaceButton += SetPreviousPage; Home.dataButton += SetDataPage; Home.settingsButton += SetSettingsPage; Home.singOut += SetPreviousPage; CurrentPage = Home; }
internal static void GetAllDbData(ToolStripDropDownItem toolStripMenu) { using (UPdatabase ctx = new UPdatabase()) { var allRows = ctx.UpData.ToList(); if (toolStripMenu.DropDownItems.Count != 0) { toolStripMenu.DropDownItems.Clear(); } foreach (var name in allRows) { toolStripMenu.DropDownItems.Add(name.ID + "-" + name.UserName, null, myClickHandler); item = ctx.UpData.FirstOrDefault(s => s.UserName == name.UserName); } } }
/* * Calls to recalculate and regraph based on user input */ // Collection of calls to update data, clear graph, regraph private void totalGraphReset() { // Update all data if (DataVM != null) { DataVM.TotalRecalculation(); } if (GraphVM != null) { GraphVM.ClearSeries(); GraphVM.GraphAllChecked(); } }
// GET: Enrollments public async Task <IActionResult> Index() { if (User.Identity.IsAuthenticated) { var vm = new DataVM(); vm.Courses = await _context.Courses.ToListAsync(); return(View(vm)); } else { return(RedirectToAction("Details", "Students")); } //var dataContext = _context.Enrollments.Include(e => e.Course).Include(e => e.Student); //return View(await dataContext.ToListAsync()); }
// Collections of calls to update only the new data (e.g. max % or # of max brackets changed) private void newDataGraphReset() { if (DataVM != null) { // Recalculate all the *new* data only DataVM.NewDataRecalcuation(); } if (GraphVM != null) { // Clear the graph GraphVM.ClearSeries(); // Graph everything that is checked GraphVM.GraphAllChecked(); } }
public ActionResult Dash() { var userId = User.Identity.GetUserId(); var householdId = db.Users.Find(userId).HouseholdId; var house = db.Households.Find(householdId); var data = new DataVM { Household = house, Banks = db.Banks.ToList(), Budgets = db.Budgets.ToList(), BudgetItems = db.BudgetItems.ToList(), Transactions = db.Transactions.ToList(), Members = db.Users.ToList() }; return(View(data)); }
//it will give section of that teacher course //api/AttendanceTeacher/GetTeacherSections/7 public HttpResponseMessage GetTeacherSections(DataVM data) //course id { //int id = 11; string empId = data.empName; // teacher login id Int32.TryParse(data.courseID, out int cid); var db = DbUtils.GetDBConnection(); db.Connection.Open(); IEnumerable <Section> response; //response = db.Query("CourseEnrollment").Where("StudentID", id).Get<CourseEnrollment>(); response = db.Query("TeacherCourseSectionDetail").Where("EmpName", empId).Where("CourseID", cid).Get <Section>(); db.Connection.Close(); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
// GET: BHTeams/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var vm = new DataVM(); vm.BHTeam = await _context.BHTeams.FirstOrDefaultAsync(m => m.BHTeamId == id); if (vm.BHTeam == null) { return(NotFound()); } vm.Players = await _context.PlayersOnTeams.Where(x => x.BHTeamId == id).ToListAsync(); _session.SetInt32("Team", vm.BHTeam.BHTeamId); return(View(vm)); }
public async Task <IActionResult> Index(DataVM dataVM) { dataVM.Data = _db.Data.FirstOrDefault(); dataVM.Phone = _db.CenterPhoneNumbers.Where(p => p.DataId == _db.Data.FirstOrDefault().Id); if (!ModelState.IsValid) { return(View()); } Reply reply = new Reply { Name = dataVM.Reply.Name, Email = dataVM.Reply.Email, Subject = dataVM.Reply.Subject, Message = dataVM.Reply.Message }; _db.Replies.Add(reply); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult DashBoard() { var userId = User.Identity.GetUserId(); var householdId = db.Users.Find(userId).HouseholdId; var house = db.Households.Find(householdId); var data = new DataVM(); data.Households = house; data.Accounts = db.MyAccounts.ToList(); data.Budgets = db.Budgets.ToList(); data.Invitations = db.Invitations.ToList(); data.Members = db.Users.ToList(); data.Transactions = db.Transactions.ToList(); data.BudgetItems = db.BudgetItems.ToList(); return(View(data)); }
protected void Page_Load(object sender, EventArgs e) { int ID; int.TryParse(Request.Form["ID"], out ID); DataSet ds = new DataSet(); using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString())) { using (SqlCommand cmd = new SqlCommand("usp_QnAType_xGetQnATypeData", sc)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ID); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { sc.Open(); da.Fill(ds); } } } List <QnATypeVM> list = new List <QnATypeVM>(); List <CreateInfoVM> list1 = new List <CreateInfoVM>(); List <ModifyInfoVM> list2 = new List <ModifyInfoVM>(); DataVM rtn = new DataVM(); EntityS.FillModel(list, ds.Tables[0]); EntityS.FillModel(list1, ds.Tables[1]); EntityS.FillModel(list2, ds.Tables[2]); rtn.Datalist = list; rtn.CreateInfo = list1; rtn.ModifyInfo = list2; Response.ContentType = "application/json; charset=utf-8"; Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn)); Response.End(); }
public DataVM SetFunctionPostDataItemError([FromBody] DataVM data) { throw new Exception("SetFunctionPostDataItemError"); }
public IActionResult Create(DataVM data) { if (data.MerchantID != 0) { //IMerchantReciept ImerchantReciept = new IMerchantReciept() { Date = data.Date, MerchantID = data.MerchantID, TotalOfReciept = data.TotalOfReciept }; //_context.Add(ImerchantReciept); //PaidForMerchant p = new PaidForMerchant() { MerchantID = data.MerchantID, Date = data.Date, Payment = data.payment, PreviousDebtsForMerchant = data.CurrentDebt, IsCash = !data.IsCash , IsPaidForUs=false , PersonID=3 }; //_context.Add(p); //var person = _context.People.Find(3); //person.credit -= data.payment; Merchant merchant = _context.Merchants.Find(data.MerchantID); merchant.PreviousDebtsForMerchant = data.CurrentDebt; _context.SaveChanges(); var FishesCookie = data.FishNames.TrimEnd(data.FishNames[data.FishNames.Length - 1]); var ProductionTypesCookie = data.ProductionTypes.TrimEnd(data.ProductionTypes[data.ProductionTypes.Length - 1]); var qtysCookie = data.qtys.TrimEnd(data.qtys[data.qtys.Length - 1]); var unitpricesCookie = data.unitprices.TrimEnd(data.unitprices[data.unitprices.Length - 1]); string[] Fishes = FishesCookie.Split(",").Select(c => Convert.ToString(c)).ToArray(); string[] Productions = ProductionTypesCookie.Split(",").Select(c => Convert.ToString(c)).ToArray(); string[] qtys = qtysCookie.Split(",").Select(c => Convert.ToString(c)).ToArray(); decimal[] unitPrices = unitpricesCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray(); IMerchantReciept imerchantReciept; Merchant m; if (data.RecID == 0) { imerchantReciept = new IMerchantReciept() { Date = data.Date, MerchantID = data.MerchantID, TotalOfReciept = data.TotalOfReciept }; _context.Add(imerchantReciept); _context.SaveChanges(); } else { imerchantReciept = _context.IMerchantReciept.Find(data.RecID); m = _context.Merchants.Find(data.MerchantID); imerchantReciept.TotalOfReciept += data.TotalOfReciept; } for (int i = 0; i < Fishes.Length; i++) { string[] splitItem = Fishes[i].Split("/").Select(c => Convert.ToString(c)).ToArray(); if (splitItem.Length > 1) { Guid amountID = Guid.NewGuid(); double[] splitItemQty = qtys[i].Split("/").Select(c => Convert.ToDouble(c)).ToArray(); for (int j = 0; j < splitItem.Length; j++) { var fish = _context.Fishes.Single(x => x.FishName == splitItem[j]); var Produc = _context.ProductionTypes.Single(x => x.ProductionName == Productions[i]); IMerchantRecieptItem NewIMerchantRecieptItems = new IMerchantRecieptItem() { IMerchantRecieptID = imerchantReciept.IMerchantRecieptID, FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = splitItemQty[j], UnitPrice = unitPrices[i], AmountId = amountID }; _context.IMerchantRecieptItem.Add(NewIMerchantRecieptItems); _context.SaveChanges(); var s = _context.Stocks.Where(c => c.FishID == fish.FishID).FirstOrDefault(); if (s != null) { if (s.ProductionTypeID == Produc.ProductionTypeID) { s.Qty += splitItemQty[j]; } else { var ss = _context.Stocks.Where(c => c.FishID == fish.FishID && c.ProductionTypeID == Produc.ProductionTypeID).FirstOrDefault(); if (ss != null) { ss.Qty += double.Parse(qtys[i]); } else { Stock stoc = new Stock() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = splitItemQty[j], Date = imerchantReciept.Date }; _context.Stocks.Add(stoc); } //Stock stoc = new Stock() //{ // FishID = fish.FishID, // ProductionTypeID = Produc.ProductionTypeID, // Qty = splitItemQty[j], // Date = imerchantReciept.Date //}; //_context.Stocks.Add(stoc); } } else { Stock stock = new Stock() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = splitItemQty[j], }; _context.Stocks.Add(stock); } var stockHistory = _context.StockHistories.ToList().Where(c => c.Date.ToShortDateString() == TimeNow().ToShortDateString() && c.FishID == fish.FishID && c.ProductionTypeID == Produc.ProductionTypeID).FirstOrDefault(); if (stockHistory != null) { stockHistory.Total += splitItemQty[j]; } else { StockHistory history = new StockHistory() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Total = splitItemQty[j], Date = TimeNow() }; _context.StockHistories.Add(history); } } } else { var fish = _context.Fishes.Single(x => x.FishName == Fishes[i]); var Produc = _context.ProductionTypes.Single(x => x.ProductionName == Productions[i]); var TodaysIMerchantRecItems = _context.IMerchantRecieptItem.Include(c => c.IMerchantReciept).ToList().Where(c => c.IMerchantReciept.Date.ToShortDateString() == TimeNow().ToShortDateString() && c.IMerchantRecieptID == imerchantReciept.IMerchantRecieptID).ToList(); var IMerchantRecieptItems = TodaysIMerchantRecItems.Where(c => c.FishID == fish.FishID && c.UnitPrice == unitPrices[i]).FirstOrDefault(); if (IMerchantRecieptItems != null) { if (IMerchantRecieptItems.ProductionTypeID == Produc.ProductionTypeID) { IMerchantRecieptItems.Qty += double.Parse(qtys[i]); } else { IMerchantRecieptItem NewIMerchantRecieptItems = new IMerchantRecieptItem() { IMerchantRecieptID = imerchantReciept.IMerchantRecieptID, FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = double.Parse(qtys[i]), UnitPrice = unitPrices[i], }; _context.IMerchantRecieptItem.Add(NewIMerchantRecieptItems); } } else { IMerchantRecieptItem NewIMerchantRecieptItems = new IMerchantRecieptItem() { IMerchantRecieptID = imerchantReciept.IMerchantRecieptID, FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = double.Parse(qtys[i]), UnitPrice = unitPrices[i], }; _context.IMerchantRecieptItem.Add(NewIMerchantRecieptItems); } _context.SaveChanges(); var s = _context.Stocks.Where(c => c.FishID == fish.FishID).FirstOrDefault(); if (s != null) { if (s.ProductionTypeID == Produc.ProductionTypeID) { s.Qty += double.Parse(qtys[i]); } else { var ss = _context.Stocks.Where(c => c.FishID == fish.FishID && c.ProductionTypeID == Produc.ProductionTypeID).FirstOrDefault(); if (ss != null) { ss.Qty += double.Parse(qtys[i]); } else { Stock stoc = new Stock() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = double.Parse(qtys[i]), Date = imerchantReciept.Date }; _context.Stocks.Add(stoc); } } } else { Stock stock = new Stock() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Qty = double.Parse(qtys[i]) }; _context.Stocks.Add(stock); } var stockHistory = _context.StockHistories.ToList().Where(c => c.Date.ToShortDateString() == TimeNow().ToShortDateString() && c.FishID == fish.FishID && c.ProductionTypeID == Produc.ProductionTypeID).FirstOrDefault(); if (stockHistory != null) { stockHistory.Total += double.Parse(qtys[i]); } else { StockHistory history = new StockHistory() { FishID = fish.FishID, ProductionTypeID = Produc.ProductionTypeID, Total = double.Parse(qtys[i]), Date = TimeNow() }; _context.StockHistories.Add(history); } } //_context.IMerchantRecieptItem.Add(IMerchantRecieptItems); _context.SaveChanges(); } var stockrows = _context.Stocks.ToList(); foreach (var item in stockrows) { if (item.ProductionTypeID == 3)//ميزان { item.TotalWeight = item.Qty; } //else //{ // //الطوايل هتتم عن طريق التصنيف //} } _context.SaveChanges(); return(Json(new { message = "success", id = imerchantReciept.IMerchantRecieptID })); //return RedirectToAction(nameof(Details),new { id= ImerchantReciept.IMerchantRecieptID }); } // ViewData["MerchantID"] = new SelectList(_context.Merchants, "MerchantID", "MerchantName", model.MerchantID); //return View(model); return(Json(new { message = "fail" })); }
public DataVM SetFunctionPostDataItem([FromBody] DataVM data) { data.Name += " +1"; return(data); }
public MainData() { InitializeComponent(); DataContext = DataVM.GetInstance(); }
void DataPage1_Loaded(object sender, RoutedEventArgs e) { vm = new DataVM((App.Current as App).UserId, this); this.DataContext = vm; }
public async Task <DataVM> SetFunctionPostDataItemSleep([FromBody] DataVM data, [FromQuery] int sleep) { data.Name += " +1"; System.Threading.Thread.Sleep(sleep); return(await Task.FromResult <DataVM>(data)); }