private void CalculateDayWage() { if (lv_Task.SelectedItems.Count != 1) { return; } wage w = lv_Task.SelectedItem as wage; double dayWage = 0; for (int i = 0; i < lv_Task.Items.Count; i++) { wage wt = lv_Task.Items.GetItemAt(i) as wage; if (w.Date == wt.Date) { dayWage += wt.Wage; } } tb_DayWage.Text = dayWage.ToString(); }
private void FillListView() { string dateString = lst_Months.SelectedItem as string; dateString += "/01"; DateTime pickedDate = new DateTime(); try { pickedDate = DateTime.Parse(dateString); } catch { MessageBox.Show("Wrong date :" + dateString); return; } List <Value> valueList = new List <Value>(); List <Assign> assginList = Db.QueryAssignByEmployeeId(LoginedEmployee.Id).ToList(); List <wage> wageList = new List <wage>(); foreach (Assign a in assginList) { ValuePrice p = Db.QueryValuePriceById(a.Price_Id).Single(); Value v = Db.QueryValueById(p.Value_Id).Single(); if (v.TaskDate > pickedDate && v.TaskDate < pickedDate.AddMonths(1)) { wage w = new wage(); w.Count = Db.QueryReckonByAssignId(a.Id).Single().Count; w.Date = v.TaskDate; w.Price = p.Unit_Price; w.Procedure = Db.QueryProcedureById(p.Procedure_Id).Single().Name; w.Product = Db.QueryProductById(v.Product_Id).Single().Name; w.Unit = p.Unit; w.Value = v.Name; w.Wage = w.Price * w.Count; wageList.Add(w); } } lv_Task.ItemsSource = wageList; CalculateMonthWage(wageList); }