protected void btnPayoff_Click(object sender, System.EventArgs e) { int year = System.Convert.ToInt32(this.hfldYear.Value.Trim()); int month = System.Convert.ToInt32(this.hfldMonth.Value.Trim()); System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); if (this.hfldCheckedId.Value.Contains("[")) { list = JsonHelper.GetListFromJson(this.hfldCheckedId.Value); } else { list.Add(this.hfldCheckedId.Value); } foreach (string userCode in list) { if (( from sps in this.saPayoffService where sps.UserCode == userCode && sps.Year == year && sps.Month == month select sps).FirstOrDefault <SAPayoff>() == null) { SAPayoff sAPayoff = new SAPayoff(); sAPayoff.Id = System.Guid.NewGuid().ToString(); sAPayoff.UserCode = userCode; sAPayoff.Year = year; sAPayoff.Month = month; sAPayoff.IsPayoff = true; sAPayoff.BooksId = this.ddlSaBooks.SelectedValue.Trim(); this.saPayoffService.Add(sAPayoff); } } this.BindGV(); }
private string GetLastBookIdByUserCode(string userCode) { string result = string.Empty; SAPayoff sAPayoff = ( from p in this.saPayoffService where p.IsPayoff == true && p.UserCode == userCode orderby p.Year descending orderby p.Month descending select p).FirstOrDefault <SAPayoff>(); if (sAPayoff != null) { result = sAPayoff.BooksId; } return(result); }
private decimal?GetLastCost(string userCode, string itemId) { decimal? result = null; SAPayoff payOff = ( from p in this.saPayoffService where p.UserCode == userCode && p.IsPayoff == true orderby p.Year descending orderby p.Month descending select p).FirstOrDefault <SAPayoff>(); if (payOff != null) { SAMonthSalary sAMonthSalary = ( from s in this.saMonthService where s.UserCode == userCode && s.Year == payOff.Year && s.Month == payOff.Month && s.ItemId == itemId select s).FirstOrDefault <SAMonthSalary>(); if (sAMonthSalary != null) { result = new decimal?(sAMonthSalary.Cost); } } return(result); }