/// <summary> /// 作成年月でデータ取得 /// </summary> /// <param name="s作成年月"></param> /// <returns></returns> public List <SERCHE_MST32010> SEARCH_GetData(string s作成年月) { DateTime d年月 = Convert.ToDateTime(s作成年月.Substring(0, 4).ToString() + "/" + s作成年月.Substring(5, 2).ToString() + "/" + "01"); int i年月1 = AppCommon.IntParse(d年月.Year.ToString() + d年月.ToString("MM")); int i年月2 = AppCommon.IntParse(d年月.AddMonths(1).Year.ToString() + d年月.AddMonths(1).ToString("MM")); int i年月3 = AppCommon.IntParse(d年月.AddMonths(2).Year.ToString() + d年月.AddMonths(2).ToString("MM")); int i年月4 = AppCommon.IntParse(d年月.AddMonths(3).Year.ToString() + d年月.AddMonths(3).ToString("MM")); int i年月5 = AppCommon.IntParse(d年月.AddMonths(4).Year.ToString() + d年月.AddMonths(4).ToString("MM")); int i年月6 = AppCommon.IntParse(d年月.AddMonths(5).Year.ToString() + d年月.AddMonths(5).ToString("MM")); int i年月7 = AppCommon.IntParse(d年月.AddMonths(6).Year.ToString() + d年月.AddMonths(6).ToString("MM")); int i年月8 = AppCommon.IntParse(d年月.AddMonths(7).Year.ToString() + d年月.AddMonths(7).ToString("MM")); int i年月9 = AppCommon.IntParse(d年月.AddMonths(8).Year.ToString() + d年月.AddMonths(8).ToString("MM")); int i年月10 = AppCommon.IntParse(d年月.AddMonths(9).Year.ToString() + d年月.AddMonths(9).ToString("MM")); int i年月11 = AppCommon.IntParse(d年月.AddMonths(10).Year.ToString() + d年月.AddMonths(10).ToString("MM")); int i年月12 = AppCommon.IntParse(d年月.AddMonths(11).Year.ToString() + d年月.AddMonths(11).ToString("MM")); using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var query = (from m05 in context.M05_CAR.Where(c => c.削除日付 == null) join m17 in context.M17_CYSN on m05.車輌KEY equals m17.車輌KEY into m17Group select new SERCHE_MST32010 { 車輌KEY = m05.車輌KEY, 車輌コード = m05.車輌ID, 車番 = m05.車輌番号, 月1 = m17Group.Where(c => c.年月 == i年月1).Select(c => c.売上予算).FirstOrDefault(), 月2 = m17Group.Where(c => c.年月 == i年月2).Select(c => c.売上予算).FirstOrDefault(), 月3 = m17Group.Where(c => c.年月 == i年月3).Select(c => c.売上予算).FirstOrDefault(), 月4 = m17Group.Where(c => c.年月 == i年月4).Select(c => c.売上予算).FirstOrDefault(), 月5 = m17Group.Where(c => c.年月 == i年月5).Select(c => c.売上予算).FirstOrDefault(), 月6 = m17Group.Where(c => c.年月 == i年月6).Select(c => c.売上予算).FirstOrDefault(), 月7 = m17Group.Where(c => c.年月 == i年月7).Select(c => c.売上予算).FirstOrDefault(), 月8 = m17Group.Where(c => c.年月 == i年月8).Select(c => c.売上予算).FirstOrDefault(), 月9 = m17Group.Where(c => c.年月 == i年月9).Select(c => c.売上予算).FirstOrDefault(), 月10 = m17Group.Where(c => c.年月 == i年月10).Select(c => c.売上予算).FirstOrDefault(), 月11 = m17Group.Where(c => c.年月 == i年月11).Select(c => c.売上予算).FirstOrDefault(), 月12 = m17Group.Where(c => c.年月 == i年月12).Select(c => c.売上予算).FirstOrDefault(), 年月1 = i年月1, 年月2 = i年月2, 年月3 = i年月3, 年月4 = i年月4, 年月5 = i年月5, 年月6 = i年月6, 年月7 = i年月7, 年月8 = i年月8, 年月9 = i年月9, 年月10 = i年月10, 年月11 = i年月11, 年月12 = i年月12, }).AsQueryable(); var queryLIST = query.ToList(); return(queryLIST); } }
/// <summary> /// 倉庫マスタ一覧検索データ取得 /// </summary> /// <returns></returns> public List <M22_SOUK_Member> GetSearchDataForList(string 庫コードFROM, string 庫コードTO, string 庫名指定, string 表示方法) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var ret = context.M22_SOUK .Where(w => w.削除日時 == null) .ToList() .Select(m22 => new M22_SOUK_Member { 庫コード = m22.庫コード, 庫名 = m22.庫名, 略称名 = m22.庫略称名, かな読み = m22.かな読み, 場所会社コード = m22.場所会社コード.ToString(), 寄託会社コード = m22.寄託会社コード.ToString(), 登録日時 = m22.登録日時, 更新日時 = m22.最終更新日時 }) .AsQueryable(); if (!(string.IsNullOrEmpty(庫コードFROM + 庫コードTO) && string.IsNullOrEmpty(庫名指定))) { if (!string.IsNullOrEmpty(庫コードFROM)) { int i倉庫コードFROM = AppCommon.IntParse(庫コードFROM); ret = ret.Where(c => c.庫コード >= i倉庫コードFROM); } if (!string.IsNullOrEmpty(庫コードTO)) { int i倉庫コードTO = AppCommon.IntParse(庫コードTO); ret = ret.Where(c => c.庫コード <= i倉庫コードTO); } if (!string.IsNullOrEmpty(庫名指定)) { ret = ret.Where(c => c.庫名.Contains(庫名指定)); } } ret = ret.Distinct(); if (表示方法 == "0") { ret = ret.OrderBy(c => c.庫コード); } else { ret = ret.OrderBy(c => c.かな読み); } return(ret.ToList()); } }
/// <summary> /// 入金明細情報の更新をおこなう /// </summary> /// <param name="context"></param> /// <param name="dt"></param> /// <param name="userId"></param> /// <returns></returns> private int setT11_NYKNDTL_Update(TRAC3Entities context, DataTable dt, int userId) { // 登録済みデータを物理削除 int i伝票番号 = AppCommon.IntParse(dt.DataSet.Tables[TABLE_HEADER].Rows[0]["伝票番号"].ToString()); var delData = context.T11_NYKNDTL.Where(w => w.伝票番号 == i伝票番号).ToList(); if (delData != null) { foreach (T11_NYKNDTL dtl in delData) { context.T11_NYKNDTL.DeleteObject(dtl); } context.SaveChanges(); } int rowIdx = 1; // 明細追加 foreach (DataRow row in dt.Rows) { if (row.RowState == DataRowState.Deleted) { continue; } T11_NYKNDTL nykndtl = new T11_NYKNDTL(); T11_NYKNDTL dtlData = convertDataRowToT11_NYKNDTL_Entity(row); if (dtlData.金種コード <= 0) { continue; } nykndtl.伝票番号 = dtlData.伝票番号; nykndtl.行番号 = rowIdx; nykndtl.金種コード = dtlData.金種コード; nykndtl.金額 = dtlData.金額; nykndtl.期日 = dtlData.期日; nykndtl.摘要 = dtlData.摘要; nykndtl.登録者 = userId; nykndtl.登録日時 = DateTime.Now; nykndtl.最終更新者 = userId; nykndtl.最終更新日時 = DateTime.Now; context.T11_NYKNDTL.ApplyChanges(nykndtl); rowIdx++; } context.SaveChanges(); return(1); }
/// <summary> /// 担当者マスタ一覧検索データ取得 /// </summary> /// <returns></returns> public List <M72_TNT_Member> GetSearchDataForList(string 担当者コードFROM, string 担当者コードTO, string 担当者指定, string 表示方法) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var ret = context.M72_TNT .Where(w => w.削除日時 == null && w.担当者ID < CommonConstants.SUPECIAL_USER_ID) .Select(s => new M72_TNT_Member { 担当者ID = s.担当者ID, 担当者名 = s.担当者名, かな読み = s.かな読み, パスワード = s.パスワード, グループ権限ID = s.グループ権限ID, 人ナンバー = s.人ナンバー, 自社コード = s.自社コード, 登録日時 = s.登録日時, 更新日時 = s.最終更新日時, }); if (!string.IsNullOrEmpty(担当者コードFROM)) { int i担当者コードFROM = AppCommon.IntParse(担当者コードFROM); ret = ret.Where(c => c.担当者ID >= i担当者コードFROM); } if (!string.IsNullOrEmpty(担当者コードTO)) { int i担当者コードTO = AppCommon.IntParse(担当者コードTO); ret = ret.Where(c => c.担当者ID <= i担当者コードTO); } if (!string.IsNullOrEmpty(担当者指定)) { ret = ret.Where(c => c.担当者名.Contains(担当者指定)); } if (表示方法 == "0") { ret = ret.OrderBy(c => c.担当者ID); } else { ret = ret.OrderBy(c => c.かな読み); } return(ret.ToList()); } }
/// <summary> /// DataRow型をS02_PAYHDエンティティに変換する /// </summary> /// <param name="dataRow"></param> /// <returns></returns> private T12_PAYHD convertDataRowToT12_PAYHD_Entity(DataRow dataRow) { T12_PAYHD payhd = new T12_PAYHD(); int iVal; payhd.伝票番号 = AppCommon.IntParse(dataRow["伝票番号"].ToString()); payhd.出金元自社コード = AppCommon.IntParse(dataRow["出金元自社コード"].ToString()); payhd.出金日 = DateTime.Parse(string.Format("{0:yyyy/MM/dd}", dataRow["出金日"])); payhd.出金先販社コード = int.TryParse(dataRow["出金先販社コード"].ToString(), out iVal) ? (int?)iVal : null; payhd.得意先コード = int.TryParse(dataRow["得意先コード"].ToString(), out iVal) ? (int?)iVal : null; payhd.得意先枝番 = int.TryParse(dataRow["得意先枝番"].ToString(), out iVal) ? (int?)iVal : null; return(payhd); }
/// <summary> /// DataRow型をT11_NYKNHDエンティティに変換する /// </summary> /// <param name="dataRow"></param> /// <returns></returns> private T11_NYKNHD convertDataRowToT11_NYKNHD_Entity(DataRow dataRow) { T11_NYKNHD nyknhd = new T11_NYKNHD(); int iVal; nyknhd.伝票番号 = AppCommon.IntParse(dataRow["伝票番号"].ToString()); nyknhd.入金先自社コード = AppCommon.IntParse(dataRow["入金先自社コード"].ToString()); nyknhd.入金日 = DateTime.Parse(string.Format("{0:yyyy/MM/dd}", dataRow["入金日"])); nyknhd.入金元販社コード = int.TryParse(dataRow["入金元販社コード"].ToString(), out iVal) ? (int?)iVal : null; nyknhd.得意先コード = int.TryParse(dataRow["得意先コード"].ToString(), out iVal) ? (int?)iVal : null; nyknhd.得意先枝番 = int.TryParse(dataRow["得意先枝番"].ToString(), out iVal) ? (int?)iVal : null; return(nyknhd); }
/// <summary> /// データ行を揚り依頼エンティティに変換して返す /// </summary> /// <param name="row"></param> /// <returns></returns> private T04_AGRWK convertDataRowToT04_AGRWK_Entity(DataRow row) { DataRowVersion ver = row.RowState == DataRowState.Deleted ? DataRowVersion.Original : DataRowVersion.Current; T04_AGRWK awk = new T04_AGRWK(); awk.SEQ = AppCommon.LongParse(row["SEQ", ver].ToString()); awk.依頼日 = AppCommon.ObjectToDate(row["依頼日", ver]) != null ? (DateTime)AppCommon.ObjectToDate(row["依頼日", ver]) : DateTime.Now; awk.取引先コード = AppCommon.IntParse(row["取引先コード", ver].ToString()); awk.枝番 = AppCommon.IntParse(row["枝番", ver].ToString()); awk.品番コード = AppCommon.IntParse(row["品番コード", ver].ToString()); awk.依頼数 = AppCommon.IntParse(row["依頼数", ver].ToString()); awk.仕上数 = AppCommon.IntParse(row["仕上数", ver].ToString()); return(awk); }
/// <summary> /// 入金明細情報の論理削除をおこなう /// </summary> /// <param name="context"></param> /// <param name="dt"></param> /// <param name="userId"></param> /// <returns></returns> private int setT11_NYKNDTL_Delete(TRAC3Entities context, DataTable dt, int userId) { // 登録済みデータを物理削除 int i伝票番号 = AppCommon.IntParse(dt.DataSet.Tables[TABLE_HEADER].Rows[0]["伝票番号"].ToString()); var delData = context.T11_NYKNDTL.Where(w => w.伝票番号 == i伝票番号).ToList(); if (delData != null) { foreach (T11_NYKNDTL dtl in delData) { dtl.削除者 = userId; dtl.削除日時 = DateTime.Now; dtl.AcceptChanges(); } } return(1); }
/// <summary> /// DataRow型をT11_NYKNDTLに変換する /// </summary> /// <param name="drow"></param> /// <returns></returns> private T11_NYKNDTL convertDataRowToT11_NYKNDTL_Entity(DataRow drow) { T11_NYKNDTL nykndtl = new T11_NYKNDTL(); DataRow wkRow = drow.Table.Clone().NewRow(); if (drow.RowState == DataRowState.Deleted) { // 対象が削除行の場合 // 対象データの参照ができるようにする DataTable wkTbl = drow.Table.Copy(); wkTbl.RejectChanges(); var orgCode = drow["行番号", DataRowVersion.Original]; foreach (DataRow dr in wkTbl.Select(string.Format("行番号 = {0}", orgCode))) { wkRow.ItemArray = dr.ItemArray; break; // 複数取る事はないと思うが念の為 } } else { wkRow.ItemArray = drow.ItemArray; } nykndtl.伝票番号 = AppCommon.IntParse(wkRow["伝票番号"].ToString()); nykndtl.行番号 = AppCommon.IntParse(wkRow["行番号"].ToString()); nykndtl.金種コード = AppCommon.IntParse(wkRow["金種コード"].ToString()); nykndtl.金額 = AppCommon.IntParse(wkRow["金額"].ToString()); if (wkRow["期日"] != null && string.IsNullOrEmpty(wkRow["期日"].ToString())) { nykndtl.期日 = null; } else { nykndtl.期日 = DateTime.Parse(wkRow["期日"].ToString()); } nykndtl.摘要 = wkRow["摘要"].ToString(); return(nykndtl); }
//No.384 Add Start /// <summary> /// 自社マスタ検索データを取得する /// </summary> /// <param name="p自社ID"></param> /// <returns></returns> public List <M70_JIS> GetDataList(string p自社ID, List <int> 対象外List, int?自社区分) { // パラメータの型変換 int iCompany = AppCommon.IntParse(p自社ID); using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); List <M70_JIS> retList = new List <M70_JIS>(); var query = context.M70_JIS.Where(w => w.削除日時 == null) .OrderBy(o => o.自社コード) .AsQueryable(); if (iCompany != 0) { // コード指定 query = query.Where(c => c.自社コード == iCompany); } if (自社区分 == 1) { // 販社のみ取得 query = query.Where(x => x.自社区分 == (int)CommonConstants.自社区分.販社); } if (対象外List.Count > 0) { query = query.Where(c => !(対象外List.Contains(c.自社コード))); } retList = query.ToList(); return(retList); } }
/// <summary> /// SRY20010 得意先売上日計表CSV /// </summary> /// <param name="p商品ID">得意先コード</param> /// <returns>S02</returns> public List <SRY20010_Member_CSV> GetDataList_CSV(string p車輌From, string p車輌To, int?[] i車輌List, string p作成締日, string p作成年, string p作成月, DateTime p集計期間To, DateTime p集計期間From, int?p自社部門コード, string 部門名) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { //支払先指定 表示用 string 支払先指定表示 = string.Empty; //query格納LIST List <SRY20010_Member_CSV> retList = new List <SRY20010_Member_CSV>(); //日付格納LIST List <SRY20010_Member_day> retList_day = new List <SRY20010_Member_day>(); int i作成年月 = p作成月.Length == 1 ? Convert.ToInt32(p作成年 + "0" + p作成月) : Convert.ToInt32(p作成年 + p作成月); //日付取得LIST for (DateTime dDate = p集計期間From; dDate <= p集計期間To; dDate = dDate.AddDays(1)) { retList_day.Add(new SRY20010_Member_day() { 日付 = dDate }); } context.Connection.Open(); //前回データ取得 var car = (from m05 in context.M05_CAR.Where(c => c.削除日付 == null) join m06 in context.M06_SYA on m05.車種ID equals m06.車種ID into m06Group from m06g in m06Group.DefaultIfEmpty() join m13 in context.M13_MOK.Where(c => c.年月 == i作成年月) on m05.車輌KEY equals m13.車輌KEY into m13Group from m13g in m13Group.DefaultIfEmpty() join t03 in context.T03_KTRN.Where(t01 => t01.経費項目ID == 401 && t01.経費発生日 < p集計期間From) on m05.車輌KEY equals t03.車輌ID into t03Group from t03g in t03Group.DefaultIfEmpty() select new SRY20010_Member_CAR { 車輌ID = m05.車輌ID, 車輌KEY = m05.車輌KEY, 車輌番号 = m05.車輌番号, 車種名 = m06g.車種名, 自社部門コード = m05.自社部門ID, 目標燃費 = m13g.目標燃費, 前回メーター = t03g.メーター, }).AsQueryable(); var carMax = (from cars in car group cars by new { cars.車輌ID, cars.車輌KEY, cars.車輌番号, cars.車種名, cars.自社部門コード, cars.目標燃費 } into Group select new { 車輌ID = Group.Key.車輌ID, 車輌KEY = Group.Key.車輌KEY, 車輌番号 = Group.Key.車輌番号, 車種名 = Group.Key.車種名, 自社部門コード = Group.Key.自社部門コード, 目標燃費 = Group.Key.目標燃費, 前回メーター = Group.Max(c => c.前回メーター), }).AsQueryable(); //締日集計処理 var query = (from y01 in retList_day from m05 in car join t03 in context.T03_KTRN.Where(t01 => t01.経費発生日 >= p集計期間From && t01.経費発生日 <= p集計期間To) on m05.車輌KEY equals t03.車輌ID into t03Group where t03Group.Where(t03 => t03.車輌ID == m05.車輌KEY).Any() == true orderby m05.車輌ID select new SRY20010_Member_CSV { 日付 = y01.日付, 車輌コード = m05.車輌ID, 車輌番号 = m05.車輌番号 == null ? "" : m05.車輌番号, 車種名 = m05.車種名 == null ? "" : m05.車種名, 給油時メーター = t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.車輌ID == m05.車輌KEY).Min(t01 => t01.メーター) == null ? 0 : t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.車輌ID == m05.車輌KEY).Min(t01 => t01.メーター), 目標燃費 = m05.目標燃費 == null ? 0 : m05.目標燃費, 前回KM = m05.前回メーター, 燃料L = t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.経費項目ID == 401).Sum(t03 => t03.数量), 自社部門コード = m05.自社部門コード, }).AsQueryable(); if (!(i車輌List.Length == 0)) { //車輌コードが検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p車輌From + p車輌To)) { query = query.Where(c => c.車輌コード >= int.MaxValue); } //車輌From処理 Min値 if (!string.IsNullOrEmpty(p車輌From)) { int?i車輌FROM = AppCommon.IntParse(p車輌From); query = query.Where(c => c.車輌コード >= i車輌FROM); } //車輌To処理 Max値 if (!string.IsNullOrEmpty(p車輌To)) { int?i車輌TO = AppCommon.IntParse(p車輌To); query = query.Where(c => c.車輌コード <= i車輌TO); } if (p自社部門コード != null) { query = query.Where(c => c.自社部門コード == p自社部門コード); } if (i車輌List.Length > 0) { var intCause = i車輌List; ////締日集計処理 query = query.Union(from y01 in retList_day from m05 in car join t03 in context.T03_KTRN.Where(t01 => t01.経費発生日 >= p集計期間From && t01.経費発生日 <= p集計期間To) on m05.車輌KEY equals t03.車輌ID into t03Group from Group in t03Group where t03Group.Where(t03 => t03.車輌ID == m05.車輌KEY).Any() == true && intCause.Contains(m05.車輌ID) orderby m05.車輌ID select new SRY20010_Member_CSV { 日付 = y01.日付, 車輌コード = m05.車輌ID, 車輌番号 = m05.車輌番号 == null ? "" : m05.車輌番号, 車種名 = m05.車種名 == "" ? "" : m05.車種名, 給油時メーター = t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.車輌ID == m05.車輌KEY).Min(t01 => t01.メーター) == null ? 0 : t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.車輌ID == m05.車輌KEY).Min(t01 => t01.メーター), 目標燃費 = m05.目標燃費 == null ? 0 : m05.目標燃費, 前回KM = m05.前回メーター, 燃料L = t03Group.Where(t03 => t03.経費発生日 == y01.日付 && t03.経費項目ID == 401).Sum(t03 => t03.数量), 自社部門コード = Group.自社部門ID, }); if (p自社部門コード != null) { query = query.Where(c => c.自社部門コード == p自社部門コード); } } } else { //車輌範囲の指定が空の場合の処理 if (!string.IsNullOrEmpty(p車輌From)) { int?i車輌FROM = AppCommon.IntParse(p車輌From); query = query.Where(c => c.車輌コード >= i車輌FROM); } if (!string.IsNullOrEmpty(p車輌To)) { int?i車輌TO = AppCommon.IntParse(p車輌To); query = query.Where(c => c.車輌コード <= i車輌TO); } //if (string.IsNullOrEmpty(p車輌From) && string.IsNullOrEmpty(p車輌To)) //{ // query = query.Where(c => c.車輌コード >= int.MinValue && c.車輌コード <= int.MaxValue); //} if (p自社部門コード != null) { query = query.Where(c => c.自社部門コード == p自社部門コード); } } //支払先指定の表示 if (i車輌List.Length > 0) { for (int it = 0; it < query.Count(); it++) { 支払先指定表示 = 支払先指定表示 + i車輌List[it].ToString(); if (it < i車輌List.Length) { if (it == i車輌List.Length - 1) { break; } 支払先指定表示 = 支払先指定表示 + ","; } if (i車輌List.Length == 1) { break; } } } query = query.Distinct(); query.OrderBy(q => new { q.車輌コード, q.日付 }); List <SRY20010_Member_CSV> queryLIST = query.ToList(); queryLIST = query.ToList(); int? i車輌コード = 0; decimal?i走行キロ = 0; for (int i = 0; i < queryLIST.Count; i++) { if (queryLIST[i].車輌コード != i車輌コード) { i走行キロ = queryLIST[i].前回KM; } i車輌コード = queryLIST[i].車輌コード; if (queryLIST[i].給油時メーター != null && queryLIST[i].給油時メーター != 0) { queryLIST[i].走行KM = queryLIST[i].給油時メーター - (i走行キロ == null ? 0 : i走行キロ); i走行キロ = queryLIST[i].給油時メーター; } if (queryLIST[i].燃料L != null && queryLIST[i].燃料L != 0 && queryLIST[i].走行KM != null) { queryLIST[i].燃費 = (queryLIST[i].走行KM / queryLIST[i].燃料L); if (queryLIST[i].燃費 == null) { queryLIST[i].燃費 = Math.Round(AppCommon.DecimalParse((queryLIST[i].走行KM / queryLIST[i].燃料L).ToString()), 0, MidpointRounding.AwayFromZero); } queryLIST[i].対目標増減 = queryLIST[i].燃費 - queryLIST[i].目標燃費; } } return(queryLIST); } }
/// <summary> /// JMI05010 印刷 /// </summary> /// <param name="p商品ID">乗務員コード</param> /// <returns>T01</returns> public List <JMI05010_Member_CSV> GetDataList_CSV(string p乗務員From, string p乗務員To, int?[] i乗務員List, int?p作成締日, DateTime?d集計期間From, DateTime?d集計期間To, string p作成年度) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <JMI05010_Member_CSV> retList = new List <JMI05010_Member_CSV>(); context.Connection.Open(); var query = (from t01 in context.T01_TRN.Where(t01 => (t01.請求日付 >= d集計期間From && t01.請求日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) join m04 in context.M04_DRV on t01.乗務員KEY equals m04.乗務員KEY into m04Group from m04G in m04Group.DefaultIfEmpty() join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01Group from m01G in m01Group.DefaultIfEmpty() where m04G.乗務員KEY != null select new JMI05010_Member_CSV { 日付 = t01.請求日付, 車番 = t01.車輌番号, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量, 重量 = t01.重量, 社内金額 = t01.支払金額, 社内立替 = t01.支払通行料, 得意先名 = m01G.略称名, 備考 = t01.請求摘要, 売上金額 = t01.売上金額 + t01.請求割増1 + t01.請求割増2, 通行料 = t01.通行料, コード = m04G.乗務員ID, 乗務員名 = m04G.乗務員名, 明細番号 = t01.明細番号, 行 = t01.明細行, }).AsQueryable(); if (!(string.IsNullOrEmpty(p乗務員From + p乗務員To) && i乗務員List.Length == 0)) { //乗務員が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p乗務員From + p乗務員To)) { query = query.Where(c => c.コード >= int.MaxValue); } //乗務員From処理 Min値 if (!string.IsNullOrEmpty(p乗務員From)) { int i乗務員FROM = AppCommon.IntParse(p乗務員From); query = query.Where(c => c.コード >= i乗務員FROM); } //乗務員To処理 Max値 if (!string.IsNullOrEmpty(p乗務員To)) { int i乗務員TO = AppCommon.IntParse(p乗務員To); query = query.Where(c => c.コード <= i乗務員TO); } if (i乗務員List.Length > 0) { var intCause = i乗務員List; query = query.Union(from t01 in context.T01_TRN.Where(t01 => (t01.請求日付 >= d集計期間From && t01.請求日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) join m04 in context.M04_DRV on t01.乗務員KEY equals m04.乗務員KEY into m04Group from m04G in m04Group.DefaultIfEmpty() join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01Group from m01G in m01Group.DefaultIfEmpty() where intCause.Contains(m04G.乗務員ID) && m04G.乗務員KEY != null select new JMI05010_Member_CSV { 日付 = t01.請求日付, 車番 = t01.車輌番号, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量, 重量 = t01.重量, 社内金額 = t01.支払金額, 社内立替 = t01.支払通行料, 得意先名 = m01G.略称名, 備考 = t01.請求摘要, 売上金額 = t01.売上金額 + t01.請求割増1 + t01.請求割増2, 通行料 = t01.通行料, コード = m04G.乗務員ID, 乗務員名 = m04G.乗務員名, 明細番号 = t01.明細番号, 行 = t01.明細行, }); } else { query = query.Where(c => c.コード > int.MinValue && c.コード < int.MaxValue); } } query = query.Distinct(); query = query.OrderBy(c => c.日付); //結果をリスト化 retList = query.ToList(); return(retList); } }
/// <summary> /// SHR09010 帳票CSV /// </summary> /// <param name="p支払先FromID">支払先コード</param> /// <returns>S02</returns> public List <SHR09010_Member_CSV> SHR09010_CSV_GetDataList(string p支払先From, string p支払先To, int?[] i支払先List, string p集金日, bool b全集金日, string p作成年, string p作成月, int 作成区分_CValue, DateTime?d集計期間From, DateTime?d集計期間To, int?集計) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <SHR09010_Member_CSV> retList = new List <SHR09010_Member_CSV>(); List <SHR09010_Member_CSV> queryList = new List <SHR09010_Member_CSV>(); context.Connection.Open(); //支払先指定 表示用 string 支払先指定表示 = string.Empty; //サイト計算 var query2 = (from m01 in context.M01_TOK.Where(m01 => m01.削除日付 == null) select new SHR09010_Member2 { 支払先ID = m01.得意先ID, 支払先名 = m01.略称名, 支払先KEY = m01.得意先KEY, サイト = m01.Sサイト日, 締日 = m01.S締日, 集金日 = m01.S集金日, 作成年月 = 集計 ?? 0, }).ToList(); DateTime d集計年月 = DateTime.Now; for (int i = 0; i < query2.Count; i++) { if (DateTime.TryParse(((p作成年).ToString() + "/" + (p作成月).ToString() + "/" + "01"), out d集計年月)) { query2[i].年月 = ((d集計年月.AddMonths(-query2[i].サイト).Year) * 100) + (d集計年月.AddMonths(-query2[i].サイト).Month); } ; } ; var query = (from q01 in query2 join s02 in context.S02_YOSS on new { q01.支払先KEY, nen = q01.年月 } equals new { s02.支払先KEY, nen = s02.集計年月 } into v01Group join nyukin in context.S02_YOSS on new { q01.支払先KEY, nen = q01.作成年月 } equals new { nyukin.支払先KEY, nen = nyukin.集計年月 } into nyukinGroup select new SHR09010_Member_CSV { 支払先コード = q01.支払先ID, 支払先名 = q01.支払先名, 集金日 = q01.集金日, サイト = q01.サイト, 支払金額 = v01Group.Sum(v01 => v01.締日売上金額), 内課税額 = v01Group.Sum(v01 => v01.締日課税売上), 消費税 = v01Group.Sum(v01 => v01.締日消費税), 支払通行料 = v01Group.Sum(v01 => v01.締日通行料), 支払予定額 = v01Group.Sum(v01 => v01.締日売上金額 + v01.締日通行料 + v01.締日消費税), 支払年月 = null, 締日 = q01.締日, 当月出金額 = nyukinGroup.Sum(v01 => v01.締日入金現金 + v01.締日入金手形), 出金調整額 = nyukinGroup.Sum(v01 => v01.締日入金その他), 出金合計額 = nyukinGroup.Sum(v01 => v01.締日入金現金 + v01.締日入金手形 + v01.締日入金その他), 集計年月 = q01.年月, 全集金日 = b全集金日 == true ? "全集金日" : p集金日 == null ? "なし" : p集金日, 対象年月 = d集計期間From, }).AsQueryable(); if (!(string.IsNullOrEmpty(p支払先From + p支払先To) && i支払先List.Length == 0)) { //支払先が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p支払先From + p支払先To)) { query = query.Where(c => c.支払先コード >= int.MaxValue); } //支払先From処理 Min値 if (!string.IsNullOrEmpty(p支払先From)) { int i支払先FROM = AppCommon.IntParse(p支払先From); query = query.Where(c => c.支払先コード >= i支払先FROM); } //支払先To処理 Max値 if (!string.IsNullOrEmpty(p支払先To)) { int i支払先TO = AppCommon.IntParse(p支払先To); query = query.Where(c => c.支払先コード <= i支払先TO); } //全締日集計処理 if (b全集金日 == true) { query = query.Where(c => c.集金日 >= 1 && c.集金日 <= 31); } //締日処理 if (!string.IsNullOrEmpty(p集金日)) { int?p変換作成締日 = AppCommon.IntParse(p集金日); query = query.Where(c => c.集金日 == p変換作成締日); } if (i支払先List.Length > 0) { var intCause = i支払先List; query = query.Union(from q01 in query2 join s02 in context.S02_YOSS on new { q01.支払先KEY, nen = q01.年月 } equals new { s02.支払先KEY, nen = s02.集計年月 } into v01Group join nyukin in context.S02_YOSS on new { q01.支払先KEY, nen = q01.作成年月 } equals new { nyukin.支払先KEY, nen = nyukin.集計年月 } into nyukinGroup where intCause.Contains(q01.支払先ID) select new SHR09010_Member_CSV { 支払先コード = q01.支払先ID, 支払先名 = q01.支払先名, 集金日 = q01.集金日, サイト = q01.サイト, 支払金額 = v01Group.Sum(v01 => v01.締日売上金額), 内課税額 = v01Group.Sum(v01 => v01.締日課税売上), 消費税 = v01Group.Sum(v01 => v01.締日消費税), 支払通行料 = v01Group.Sum(v01 => v01.締日通行料), 支払予定額 = v01Group.Sum(v01 => v01.締日売上金額 + v01.締日通行料 + v01.締日消費税), 支払年月 = null, 締日 = q01.締日, 当月出金額 = nyukinGroup.Sum(v01 => v01.締日入金現金 + v01.締日入金手形), 出金調整額 = nyukinGroup.Sum(v01 => v01.締日入金その他), 出金合計額 = nyukinGroup.Sum(v01 => v01.締日入金現金 + v01.締日入金手形 + v01.締日入金その他), 集計年月 = q01.年月, 全集金日 = b全集金日 == true ? "全集金日" : p集金日 == null ? "なし" : p集金日, 対象年月 = d集計期間From, }).AsQueryable(); //全締日集計処理 if (b全集金日 == true) { query = query.Where(c => c.集金日 >= 1 && c.集金日 <= 31); } //締日処理 if (!string.IsNullOrEmpty(p集金日)) { int?p変換作成締日 = AppCommon.IntParse(p集金日); query = query.Where(c => c.集金日 == p変換作成締日); } } } else { //支払先From処理 Min値 if (string.IsNullOrEmpty(p支払先From)) { query = query.Where(c => c.支払先コード >= int.MinValue); } //支払先To処理 Max値 if (string.IsNullOrEmpty(p支払先To)) { query = query.Where(c => c.支払先コード <= int.MaxValue); } //全締日集計処理 if (b全集金日 == true) { query = query.Where(c => c.集金日 >= 1 && c.集金日 <= 31); } //締日処理 if (!string.IsNullOrEmpty(p集金日)) { int?p変換作成締日 = AppCommon.IntParse(p集金日); query = query.Where(c => c.集金日 == p変換作成締日); } } //内訳別表示処理 //売上あり:0 //売上なし:1 switch (作成区分_CValue) { //支払取引全体 case 0: query = query.Where(c => c.支払予定額 != 0); break; //支払先 case 1: //query = query.Where(c => c.支払予定額 >= 0); break; default: break; } //支払先指定の表示 if (i支払先List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 支払先指定表示 = 支払先指定表示 + i支払先List[i].ToString(); if (i < i支払先List.Length) { if (i == i支払先List.Length - 1) { break; } 支払先指定表示 = 支払先指定表示 + ","; } if (i支払先List.Length == 1) { break; } } } //必要のないデータの削除 //queryList = query.ToList(); //int cnt = 0; //for (int i = 0; i < queryList.Count; i++) //{ // if (queryList[i].出金合計額 == 0) // { // cnt++; // } // else // { // cnt--; // } // if (Convert.ToInt32(queryList.Count()) == cnt) // { // queryList.RemoveAll(c => c.当月出金額 == 0); // } // else // { // continue; // } //} List <SHR09010_Member_CSV> queryLIST = queryList; for (int i = 0; i < queryLIST.Count(); i++) { if (queryLIST[i].支払年月 == null) { if (queryLIST[i].サイト != null) { DateTime Wk; if (DateTime.TryParse(p作成年 + "/" + p作成月 + "/" + "01", out Wk)) { DateTime dtBirth = Wk; dtBirth = dtBirth.AddMonths(Convert.ToInt32(-queryLIST[i].サイト)); queryLIST[i].支払年月 = dtBirth; } } } } //出力 return(queryLIST.ToList()); } }
public List <SHR12010_Member> SHR12010_GetDataHinList(string s取引先From, string s取引先To, int?[] i取引先List, int i作成年, int i作成月, int i作成年月, int i作成区分, int i取引区分, string s作成年月度) { string 取引先指定ピックアップ = string.Empty; using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <SHR12010_Member> retList = new List <SHR12010_Member>(); context.Connection.Open(); //売上データ取得 var Value1 = (from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3).DefaultIfEmpty() join s01 in context.S01_TOKS.Where(c => c.回数 == 1).DefaultIfEmpty() on m01.得意先KEY equals s01.得意先KEY into Group from s01Group in Group.Where(c => c.集計年月 == i作成年月) group new { m01, s01Group } by new { m01.得意先ID, m01.略称名, m01.親子区分ID, m01.T締日, m01.取引区分 } into grGroup select new SHR12010_Value1 { 取引先ID = grGroup.Key.得意先ID, 取引先名 = grGroup.Key.略称名, 取引区分 = grGroup.Key.取引区分, 親子区分 = grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ?"親" : "子", 締日 = grGroup.Key.T締日, 売上金額 = grGroup.Sum(c => c.s01Group.締日売上金額) == null ? 0 : grGroup.Sum(c => c.s01Group.締日売上金額), 売上消費税 = grGroup.Sum(c => c.s01Group.締日消費税) == null ? 0 : grGroup.Sum(c => c.s01Group.締日消費税), 通行料 = grGroup.Sum(c => c.s01Group.締日通行料) == null ? 0 : grGroup.Sum(c => c.s01Group.締日通行料), 売上金額計 = grGroup.Sum(c => c.s01Group.締日売上金額 + c.s01Group.締日消費税 + c.s01Group.締日通行料) == null ? 0 : grGroup.Sum(c => c.s01Group.締日売上金額 + c.s01Group.締日消費税 + c.s01Group.締日通行料), }).AsQueryable(); var Sales = (from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3) from sal in Value1.Where(c => c.取引先ID == m01.得意先ID).DefaultIfEmpty() select new SHR12010_Sales { 取引先ID = m01.得意先ID, 取引先名 = m01.略称名, 取引区分 = m01.取引区分, 親子区分 = m01.親子区分ID == 0 ? "" : m01.親子区分ID == 1 ? "親" : m01.親子区分ID == 2 ? "親" : "子", 締日 = m01.T締日, 売上金額 = Value1.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.売上金額) == null ? 0 : sal.売上金額, 売上消費税 = Value1.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.売上消費税) == null ? 0 : sal.売上消費税, 通行料 = Value1.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.通行料) == null ? 0 : sal.通行料, 売上金額計 = Value1.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.売上金額計) == null ? 0 : sal.売上金額計, }).AsQueryable(); //支払データ取得 var Value2 = (from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3).DefaultIfEmpty() join s02 in context.S02_YOSS.Where(c => c.回数 == 1).DefaultIfEmpty() on m01.得意先KEY equals s02.支払先KEY into Group from s02Group in Group.Where(c => c.集計年月 == i作成年月) group new { m01, s02Group } by new { m01.得意先ID, m01.略称名, m01.親子区分ID, s02Group.締日, m01.取引区分 } into grGroup select new SHR12010_Value2 { 取引先ID = grGroup.Key.得意先ID, 取引先名 = grGroup.Key.略称名, 取引区分 = grGroup.Key.取引区分, 親子区分 = grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ?"親" : "子", 締日 = grGroup.Key.締日, 支払合計 = grGroup.Sum(c => c.s02Group.締日売上金額) == null ? 0 : grGroup.Sum(c => c.s02Group.締日売上金額), 傭車金額 = grGroup.Sum(c => c.s02Group.締日売上金額) == null ? 0 : grGroup.Sum(c => c.s02Group.締日売上金額), 支払消費税 = grGroup.Sum(c => c.s02Group.締日消費税) == null ? 0 : grGroup.Sum(c => c.s02Group.締日消費税), 支払通行料 = grGroup.Sum(c => c.s02Group.締日通行料) == null ? 0 : grGroup.Sum(c => c.s02Group.締日通行料), 傭車金額計 = grGroup.Sum(c => c.s02Group.締日売上金額 + c.s02Group.締日消費税 + c.s02Group.締日通行料) == null ? 0 :grGroup.Sum(c => c.s02Group.締日売上金額 + c.s02Group.締日消費税 + c.s02Group.締日通行料), }).AsQueryable(); var Payment = (from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3) from pay in Value2.Where(c => c.取引先ID == m01.得意先ID).DefaultIfEmpty() select new SHR12010_Payment { 取引先ID = m01.得意先ID, 取引先名 = m01.略称名, 取引区分 = m01.取引区分, 親子区分 = m01.親子区分ID == 0 ? "" : m01.親子区分ID == 1 ? "親" : m01.親子区分ID == 2 ? "親" : "子", 締日 = m01.T締日, 支払合計 = Value2.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.支払合計) == null ? 0 : pay.支払合計, 傭車金額 = Value2.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.傭車金額) == null ? 0 : pay.傭車金額, 支払消費税 = Value2.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.支払消費税) == null ? 0 : pay.支払消費税, 支払通行料 = Value2.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.支払通行料) == null ? 0 : pay.支払通行料, 傭車金額計 = Value2.Where(c => c.取引先ID == m01.得意先ID).Sum(c => c.傭車金額計) == null ? 0 : pay.傭車金額計, }).AsQueryable(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region 売上と支払データ if (Sales.Count() != 0 && Payment.Count() != 0) { //2つのクエリの【和集合】を求める var retquery = (from s01 in Sales select s01.取引先ID).Union( from s02 in Payment select s02.取引先ID).AsQueryable(); var query = (from ret in retquery from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3).DefaultIfEmpty() from s01 in Sales.Where(c => c.取引先ID == ret).DefaultIfEmpty() from s02 in Payment.Where(c => c.取引先ID == ret).DefaultIfEmpty() where ret == m01.得意先ID group new { m01, s01, s02 } by new { m01.得意先ID, m01.略称名, m01.取引区分, m01.親子区分ID, m01.T締日 } into grGroup select new SHR12010_Member { 取引先ID = grGroup.Key.得意先ID == null ? 0 : grGroup.Key.得意先ID, 取引先名 = grGroup.Key.略称名 == null ? "" : grGroup.Key.略称名, 取引区分 = grGroup.Key.取引区分 == null ? 0 : grGroup.Key.取引区分, 親子区分 = grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子" == null ? "" : grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子", 締日 = grGroup.Key.T締日 == null ? 0 : grGroup.Key.T締日, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }).Distinct().AsQueryable(); if (!(string.IsNullOrEmpty(s取引先From + s取引先To) && i取引先List.Length == 0)) { if (string.IsNullOrEmpty(s取引先From + s取引先To)) { query = query.Where(c => c.取引先ID >= int.MaxValue); } //取引先From if (!string.IsNullOrEmpty(s取引先From)) { int i取引先From = AppCommon.IntParse(s取引先From); query = query.Where(c => c.取引先ID >= i取引先From); } //取引先To if (!string.IsNullOrEmpty(s取引先To)) { int i取引先To = AppCommon.IntParse(s取引先To); query = query.Where(c => c.取引先ID <= i取引先To); } //取引先ピックアップ if (i取引先List.Length > 0) { var intCause = i取引先List; //全件表示 query = query.Union(from ret in retquery from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3) from s01 in Sales.Where(c => c.取引先ID == ret).DefaultIfEmpty() from s02 in Payment.Where(c => c.取引先ID == ret).DefaultIfEmpty() where ret == m01.得意先ID && intCause.Contains(m01.得意先ID) group new { m01, s01, s02 } by new { m01.得意先ID, m01.略称名, m01.取引区分, m01.親子区分ID, m01.T締日 } into grGroup select new SHR12010_Member { 取引先ID = grGroup.Key.得意先ID == null ? 0 : grGroup.Key.得意先ID, 取引先名 = grGroup.Key.略称名 == null ? "" : grGroup.Key.略称名, 取引区分 = grGroup.Key.取引区分 == null ? 0 : grGroup.Key.取引区分, 親子区分 = grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子" == null ? "" : grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子", 締日 = grGroup.Key.T締日 == null ? 0 : grGroup.Key.T締日, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }).Distinct().AsQueryable(); //取引先指定の表示 if (i取引先List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 取引先指定ピックアップ = 取引先指定ピックアップ + i取引先List[i].ToString(); if (i < i取引先List.Length) { if (i == i取引先List.Length - 1) { break; } 取引先指定ピックアップ = 取引先指定ピックアップ + ","; } if (i取引先List.Length == 1) { break; } } } } } else { //s取引先FromがNULLだった場合 if (string.IsNullOrEmpty(s取引先From)) { query = query.Where(c => c.取引先ID >= int.MinValue); } //s取引先ToがNullだった場合 if (string.IsNullOrEmpty(s取引先To)) { query = query.Where(c => c.取引先ID <= int.MaxValue); } } //【売上】・【支払】・【売上/支払】データをList化 List <SHR12010_Member> queryLIST = query.ToList(); List <SHR12010_Sales> SalesList = Sales.ToList(); List <SHR12010_Payment> PaymentList = Payment.ToList(); //売上と支払を1つにしたデータをLoop for (int i = 0; i < queryLIST.Count(); i++) { //QueryListに当てはまる【売上】データがある場合、データ挿入 for (int x = 0; x < SalesList.Count(); x++) { if (queryLIST[i].取引先ID == SalesList[x].取引先ID) { queryLIST[i].売上金額 = SalesList[x].売上金額; queryLIST[i].売上金額計 = SalesList[x].売上金額計; queryLIST[i].売上消費税 = SalesList[x].売上消費税; queryLIST[i].通行料 = SalesList[x].通行料; } else { continue; } } //QueryListに当てはまる【支払】データがある場合、データ挿入 for (int y = 0; y < PaymentList.Count(); y++) { if (queryLIST[i].取引先ID == PaymentList[y].取引先ID) { queryLIST[i].傭車金額 = PaymentList[y].傭車金額; queryLIST[i].傭車金額計 = PaymentList[y].傭車金額計; queryLIST[i].支払消費税 = PaymentList[y].支払消費税; queryLIST[i].支払通行料 = PaymentList[y].支払通行料; } else { continue; } } } //帳票の【売上額】と【支払額】を比較して額が多いほうの差分データを挿入 for (int i = 0; i < queryLIST.Count(); i++) { if (queryLIST[i].売上金額計 > queryLIST[i].傭車金額計) { queryLIST[i].売上合計 = queryLIST[i].売上金額計 - queryLIST[i].傭車金額計; } else if (queryLIST[i].売上金額計 < queryLIST[i].傭車金額計) { queryLIST[i].支払合計 = queryLIST[i].傭車金額計 - queryLIST[i].売上金額計; } else { continue; } } //作成区分が0だった場合 if (i作成区分 == 0) { //売上・支払が発生していないデータを除く queryLIST = queryLIST.Where(c => c.売上金額計 != 0 || c.傭車金額計 != 0).ToList(); } //取引区分が1だった場合【全取引】のみのデータを取得 if (i取引区分 == 1) { queryLIST = queryLIST.Where(c => c.取引区分 == 0).ToList(); } //親子区分が【子】のデータを除外 queryLIST = queryLIST.Where(c => c.親子区分 != "子").ToList(); return(queryLIST.ToList()); } #endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region 売上のみのデータがある場合 else if (Sales.Count() != 0 && Payment.Count() == 0) { var Cord = (from s01 in Sales select new SHR12010_Cord { 取引先ID = s01.取引先ID == null ? 0 : s01.取引先ID, 取引先名 = s01.取引先名 == null ? "なし" : s01.取引先名, 取引区分 = s01.取引区分 == null ? 0 : s01.取引区分, 親子区分 = s01.親子区分 == null ? "なし" : s01.親子区分, 締日 = s01.締日 == null ? 0 : s01.締日, }).Distinct().AsQueryable(); //全件表示 var query = (from Cor in Cord join s01 in Sales on Cor.取引先ID equals s01.取引先ID into s01Group from S01Group in s01Group.DefaultIfEmpty() group S01Group by new { Cor.取引先ID, Cor.取引先名, Cor.取引区分, Cor.親子区分, Cor.締日, S01Group.売上金額, S01Group.売上消費税, S01Group.通行料, S01Group.売上金額計, } into grGroup select new SHR12010_Member { 取引先ID = grGroup.Key.取引先ID, 取引先名 = grGroup.Key.取引先名, 親子区分 = grGroup.Key.親子区分, 締日 = grGroup.Key.締日, 売上金額 = grGroup.Key.売上金額 == null ? 0 : grGroup.Key.売上金額, 売上消費税 = grGroup.Key.売上消費税 == null ? 0 : grGroup.Key.売上消費税, 通行料 = grGroup.Key.通行料 == null ? 0 : grGroup.Key.通行料, 売上金額計 = grGroup.Key.売上金額計 == null ? 0 : grGroup.Key.売上金額計, 傭車金額 = 0, 支払消費税 = 0, 支払通行料 = 0, 傭車金額計 = 0, 売上合計 = grGroup.Key.売上金額計, 支払合計 = 0, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }).AsQueryable(); if (!(string.IsNullOrEmpty(s取引先From + s取引先To) && i取引先List.Length == 0)) { if (string.IsNullOrEmpty(s取引先From + s取引先To)) { query = query.Where(c => c.取引先ID >= int.MaxValue); } //取引先From if (!string.IsNullOrEmpty(s取引先From)) { int i取引先From = AppCommon.IntParse(s取引先From); query = query.Where(c => c.取引先ID >= i取引先From); } //取引先To if (!string.IsNullOrEmpty(s取引先To)) { int i取引先To = AppCommon.IntParse(s取引先To); query = query.Where(c => c.取引先ID <= i取引先To); } //取引先ピックアップ if (i取引先List.Length > 0) { var intCause = i取引先List; //全件表示 query = query.Union(from Cor in Cord join s01 in Sales on Cor.取引先ID equals s01.取引先ID into s01Group from S01Group in s01Group.DefaultIfEmpty() group S01Group by new { Cor.取引先ID, Cor.取引先名, Cor.取引区分, Cor.親子区分, Cor.締日, S01Group.売上金額, S01Group.売上消費税, S01Group.通行料, S01Group.売上金額計, } into grGroup where intCause.Contains(grGroup.Key.取引先ID) select new SHR12010_Member { 取引先ID = grGroup.Key.取引先ID, 取引先名 = grGroup.Key.取引先名, 親子区分 = grGroup.Key.親子区分, 締日 = grGroup.Key.締日, 売上金額 = grGroup.Key.売上金額 == null ? 0 : grGroup.Key.売上金額, 売上消費税 = grGroup.Key.売上消費税 == null ? 0 : grGroup.Key.売上消費税, 通行料 = grGroup.Key.通行料 == null ? 0 : grGroup.Key.通行料, 売上金額計 = grGroup.Key.売上金額計 == null ? 0 : grGroup.Key.売上金額計, 傭車金額 = 0, 支払消費税 = 0, 支払通行料 = 0, 傭車金額計 = 0, 売上合計 = grGroup.Key.売上金額計, 支払合計 = 0, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }); } } else { //s取引先FromがNULLだった場合 if (string.IsNullOrEmpty(s取引先From)) { query = query.Where(c => c.取引先ID >= int.MinValue); } //s取引先ToがNullだった場合 if (string.IsNullOrEmpty(s取引先To)) { query = query.Where(c => c.取引先ID <= int.MaxValue); } } //取引先指定の表示 if (i取引先List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 取引先指定ピックアップ = 取引先指定ピックアップ + i取引先List[i].ToString(); if (i < i取引先List.Length) { if (i == i取引先List.Length - 1) { break; } 取引先指定ピックアップ = 取引先指定ピックアップ + ","; } if (i取引先List.Length == 1) { break; } } } //作成区分が0だった場合 if (i作成区分 == 0) { //売上・支払が発生していないデータを除く query = query.Where(c => c.売上金額計 != 0 || c.傭車金額計 != 0); } //取引区分が1だった場合【全取引】のみのデータを取得 if (i取引区分 == 1) { query = query.Where(c => c.取引区分 == 0); } //親子区分が【子】のデータを除外 query = query.Where(c => c.親子区分 != "子"); return(query.ToList()); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region 支払のみのデータがある場合 else if (Sales.Count() == 0 && Payment.Count() != 0) { var Cord = (from s02 in Payment select new SHR12010_Cord { 取引先ID = s02.取引先ID == null ? 0 : s02.取引先ID, 取引先名 = s02.取引先名 == null ? "なし" : s02.取引先名, 取引区分 = s02.取引区分 == null ? 0 : s02.取引区分, 親子区分 = s02.親子区分 == null ? "なし" : s02.親子区分, 締日 = s02.締日 == null ? 0 : s02.締日, }).Distinct().AsQueryable(); //全件表示 var query = (from Cor in Cord join s02 in Payment on Cor.取引先ID equals s02.取引先ID into s02Group from S02Group in s02Group.DefaultIfEmpty() group S02Group by new { Cor.取引先ID, Cor.取引先名, Cor.取引区分, Cor.親子区分, Cor.締日, S02Group.支払合計, S02Group.傭車金額, S02Group.支払消費税, S02Group.支払通行料, S02Group.傭車金額計, } into grGroup select new SHR12010_Member { 取引先ID = grGroup.Key.取引先ID, 取引先名 = grGroup.Key.取引先名, 親子区分 = grGroup.Key.親子区分, 締日 = grGroup.Key.締日, 売上金額 = 0, 売上消費税 = 0, 通行料 = 0, 売上金額計 = 0, 傭車金額 = grGroup.Key.傭車金額 == null ? 0 : grGroup.Key.傭車金額, 支払消費税 = grGroup.Key.支払消費税 == null ? 0 : grGroup.Key.支払消費税, 支払通行料 = grGroup.Key.支払通行料 == null ? 0 : grGroup.Key.支払通行料, 傭車金額計 = grGroup.Key.傭車金額計 == null ? 0 : grGroup.Key.傭車金額計, 売上合計 = 0, 支払合計 = grGroup.Key.傭車金額計 == null ? 0 : grGroup.Key.傭車金額計, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }).AsQueryable(); if (!(string.IsNullOrEmpty(s取引先From + s取引先To) && i取引先List.Length == 0)) { if (string.IsNullOrEmpty(s取引先From + s取引先To)) { query = query.Where(c => c.取引先ID >= int.MaxValue); } //取引先From if (!string.IsNullOrEmpty(s取引先From)) { int i取引先From = AppCommon.IntParse(s取引先From); query = query.Where(c => c.取引先ID >= i取引先From); } //取引先To if (!string.IsNullOrEmpty(s取引先To)) { int i取引先To = AppCommon.IntParse(s取引先To); query = query.Where(c => c.取引先ID <= i取引先To); } //取引先ピックアップ if (i取引先List.Length > 0) { var intCause = i取引先List; //全件表示 query = query.Union(from Cor in Cord join s02 in Payment on Cor.取引先ID equals s02.取引先ID into s02Group from S02Group in s02Group.DefaultIfEmpty() group S02Group by new { Cor.取引先ID, Cor.取引先名, Cor.取引区分, Cor.親子区分, Cor.締日, S02Group.支払合計, S02Group.傭車金額, S02Group.支払消費税, S02Group.支払通行料, S02Group.傭車金額計, } into grGroup where intCause.Contains(grGroup.Key.取引先ID) select new SHR12010_Member { 取引先ID = grGroup.Key.取引先ID, 取引先名 = grGroup.Key.取引先名, 親子区分 = grGroup.Key.親子区分, 締日 = grGroup.Key.締日, 売上金額 = 0, 売上消費税 = 0, 通行料 = 0, 売上金額計 = 0, 傭車金額 = grGroup.Key.傭車金額 == null ? 0 : grGroup.Key.傭車金額, 支払消費税 = grGroup.Key.支払消費税 == null ? 0 : grGroup.Key.支払消費税, 支払通行料 = grGroup.Key.支払通行料 == null ? 0 : grGroup.Key.支払通行料, 傭車金額計 = grGroup.Key.傭車金額計 == null ? 0 : grGroup.Key.傭車金額計, 売上合計 = 0, 支払合計 = grGroup.Key.傭車金額計 == null ? 0 : grGroup.Key.傭車金額計, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, }); } } else { //s取引先FromがNULLだった場合 if (string.IsNullOrEmpty(s取引先From)) { query = query.Where(c => c.取引先ID >= int.MinValue); } //s取引先ToがNullだった場合 if (string.IsNullOrEmpty(s取引先To)) { query = query.Where(c => c.取引先ID <= int.MaxValue); } } //取引先指定の表示 if (i取引先List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 取引先指定ピックアップ = 取引先指定ピックアップ + i取引先List[i].ToString(); if (i < i取引先List.Length) { if (i == i取引先List.Length - 1) { break; } 取引先指定ピックアップ = 取引先指定ピックアップ + ","; } if (i取引先List.Length == 1) { break; } } } //作成区分が0だった場合 if (i作成区分 == 0) { //売上・支払が発生していないデータを除く query = query.Where(c => c.売上金額計 != 0 || c.傭車金額計 != 0); } //取引区分が1だった場合【全取引】のみのデータを取得 if (i取引区分 == 1) { query = query.Where(c => c.取引区分 == 0); } //親子区分が【子】のデータを除外 query = query.Where(c => c.親子区分 != "子"); return(query.ToList()); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// else { var query = ( from m01 in context.M01_TOK.Where(c => c.削除日付 == null && c.親子区分ID != 3) from s01 in context.S01_TOKS.Where(c => c.得意先KEY == m01.得意先KEY && c.回数 == 1).DefaultIfEmpty() from s02 in context.S02_YOSS.Where(c => c.支払先KEY == m01.得意先KEY && c.回数 == 1).DefaultIfEmpty() group new { m01, s01, s02 } by new { m01.得意先ID, m01.略称名, m01.取引区分, m01.親子区分ID, m01.T締日 } into grGroup select new SHR12010_Member { 取引先ID = grGroup.Key.得意先ID == null ? 0 : grGroup.Key.得意先ID, 取引先名 = grGroup.Key.略称名 == null ? "" : grGroup.Key.略称名, 取引区分 = grGroup.Key.取引区分 == null ? 0 : grGroup.Key.取引区分, 親子区分 = grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子" == null ? "" : grGroup.Key.親子区分ID == 0 ? "" : grGroup.Key.親子区分ID == 1 ? "親" : grGroup.Key.親子区分ID == 2 ? "親" : "子", 締日 = grGroup.Key.T締日 == null ? 0 : grGroup.Key.T締日, 作成年月度 = s作成年月度, 取引先指定 = s取引先From + "~" + s取引先To, 取引先ピックアップ = 取引先指定ピックアップ == "" ? "" : 取引先指定ピックアップ, 売上金額 = 0, 売上消費税 = 0, 通行料 = 0, 売上金額計 = 0, 傭車金額 = 0, 支払消費税 = 0, 支払通行料 = 0, 傭車金額計 = 0, 売上合計 = 0, 支払合計 = 0, }).Distinct().AsQueryable(); //作成区分が0だった場合 if (i作成区分 == 0) { //売上・支払が発生していないデータを除く query = query.Where(c => c.売上金額計 != 0 || c.傭車金額計 != 0); } return(query.ToList()); } } }
public List <SRY13010_Member_CSV> SRY13010_GetData_CSV(string s車種From, string s車種To, int?[] i車種List, string s車種List, DateTime d集計期間From, DateTime d集計期間To) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { int i集計期間From = AppCommon.IntParse(d集計期間From.ToString("yyyyMM")); int i集計期間To = AppCommon.IntParse(d集計期間To.ToString("yyyyMM")); List <SRY13010_Member_CSV> retList = new List <SRY13010_Member_CSV>(); context.Connection.Open(); try { var 車種自社締日 = (from m87 in context.M87_CNTL.Where(m87 => m87.管理ID == 1) select new { m87.車輌自社締日 }).ToList(); int iSime = AppCommon.IntParse(車種自社締日[0].車輌自社締日.ToString()); iSime += 1; if ((iSime) >= 32) { iSime = 1; } if (iSime.ToString().Length == 1) { if (!DateTime.TryParse(d集計期間From.ToString("yyyy/MM/0") + iSime.ToString(), out d集計期間From)) { return(retList); } } else { if (!DateTime.TryParse(d集計期間From.ToString("yyyy/MM/") + iSime.ToString(), out d集計期間From)) { return(retList); } } var query3 = (from m06 in context.M06_SYA.Where(m06 => m06.削除日付 == null) join m05 in context.M05_CAR.Where(m05 => m05.削除日付 == null) on m06.車種ID equals m05.車種ID into m05Group select new { m06.車種ID, m06.登録日時, m06.更新日時, m06.車種名, m06.積載重量, m06.削除日付, 台数 = m05Group.Count(m05g => m05g.廃車区分 == 0) } ); var query2 = (from s14sb in context.V_車種月次サブ join m07 in context.M07_KEI on s14sb.経費項目ID equals m07.経費項目ID into m07Group select new { s14sb.金額, s14sb.経費項目ID, s14sb.経費項目名, s14sb.固定変動区分, s14sb.車種ID, s14sb.集計年月, m07Group.FirstOrDefault().経費区分 } ); var query = (from m06 in query3 join s14 in context.V_車種月別売上合計表.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m06.車種ID equals s14.車種ID into s14Group join s14sb in query2.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m06.車種ID equals s14sb.車種ID into s14sbGroup select new SRY13010_Member_CSV { コード = m06.車種ID, 車種名 = m06.車種名, 台数 = m06.台数, 収入日数 = s14Group.Sum(c => c.稼動日数) == 0 ? 0 : Math.Round((decimal)(s14Group.Sum(c => c.運送収入) / s14Group.Sum(c => c.稼動日数)), 0), 収入時間 = (s14Group.Sum(c => c.拘束時間) * 60) == 0 ? 0 : Math.Round((decimal)((s14Group.Sum(c => c.運送収入) * 60) / s14Group.Sum(c => c.拘束時間)), 0), 収入KM = s14Group.Sum(c => c.走行KM) == 0 ? 0 : Math.Round((decimal)(s14Group.Sum(c => c.運送収入) / s14Group.Sum(c => c.走行KM)), 0), 収入屯数 = s14Group.Sum(c => c.輸送屯数) == 0 ? 0 : Math.Round((decimal)(s14Group.Sum(c => c.運送収入) / s14Group.Sum(c => c.輸送屯数)), 0), 固定費日数 = s14Group.Sum(c => c.稼動日数) == 0 ? 0 : Math.Round((decimal)(s14sbGroup.Where(c => c.固定変動区分 == 0).Sum(c => c.金額) / s14Group.Sum(c => c.稼動日数)), 0), 動費KM = s14Group.Sum(c => c.走行KM) == 0 ? 0 : Math.Round((decimal)(s14sbGroup.Where(c => c.固定変動区分 == 1).Sum(c => c.金額) / s14Group.Sum(c => c.走行KM)), 0), 修理日数 = s14Group.Sum(c => c.稼動日数) == 0 ? 0 : Math.Round((decimal)(s14sbGroup.Where(c => c.経費項目ID == s14sbGroup.Where(d => d.経費区分 == 5).Min(d => d.経費項目ID)).Sum(c => c.金額) / s14Group.Sum(c => c.稼動日数)), 0), 修理KM = s14Group.Sum(c => c.走行KM) == 0 ? 0 : Math.Round((decimal)(s14sbGroup.Where(c => c.経費項目ID == s14sbGroup.Where(d => d.経費区分 == 5).Min(d => d.経費項目ID)).Sum(c => c.金額) / s14Group.Sum(c => c.走行KM)), 0), 益日数 = s14Group.Sum(c => c.稼動日数) == 0 ? 0 : Math.Round((decimal)((s14Group.Sum(c => c.運送収入) - s14sbGroup.Sum(c => c.金額)) / s14Group.Sum(c => c.稼動日数)), 0), 益KM = s14Group.Sum(c => c.走行KM) == 0 ? 0 : Math.Round((decimal)((s14Group.Sum(c => c.運送収入) - s14sbGroup.Sum(c => c.金額)) / s14Group.Sum(c => c.走行KM)), 0), }).AsQueryable(); query = query.Distinct(); query = query.Where(c => c.台数 != 0); int i車種FROM; int i車種TO; //部門From処理 Min値 if (!string.IsNullOrEmpty(s車種From)) { i車種FROM = AppCommon.IntParse(s車種From); } else { i車種FROM = int.MinValue; } //部門To処理 Max値 if (!string.IsNullOrEmpty(s車種To)) { i車種TO = AppCommon.IntParse(s車種To); } else { i車種TO = int.MaxValue; } var intCause = i車種List; if (string.IsNullOrEmpty(s車種From + s車種To)) { if (i車種List.Length > 0) { query = query.Where(q => intCause.Contains(q.コード)); } } else { if (i車種List.Length > 0) { query = query.Where(q => intCause.Contains(q.コード) || (q.コード >= i車種FROM && q.コード <= i車種TO)); } else { query = query.Where(q => (q.コード >= i車種FROM && q.コード <= i車種TO)); } } query = query.Distinct(); retList = query.ToList(); return(retList); } catch (Exception ex) { throw ex; } } }
/// <summary> /// DLY19010 印刷 /// </summary> /// <param name="p商品ID">乗務員コード</param> /// <returns>T01</returns> public List <DLY19010_Member> GetDataList(string p乗務員From, string p乗務員To, int?[] i乗務員List, DateTime?d集計期間From, DateTime?d集計期間To, int i部門指定) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <DLY19010_Member> retList = new List <DLY19010_Member>(); context.Connection.Open(); var query = (from m04 in context.M04_DRV from t01 in context.T01_TRN.Where(t01 => m04.乗務員KEY == t01.乗務員KEY && (t01.配送日付 >= d集計期間From && t01.配送日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01Group from m01G in m01Group join m05 in context.M05_CAR on t01.車輌KEY equals m05.車輌KEY into m05Group from m05G in m05Group where m04.削除日付 == null select new DLY19010_Member { 車輌コード = m05G.車輌ID, 乗務員コード = m04.乗務員ID, 日付 = t01.請求日付, 車番 = t01.車輌番号, 乗務員名 = m04.乗務員名, 得意先名 = m01G.略称名, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量 == null ? 0 : t01.数量, 重量 = t01.重量 == null ? 0 : t01.重量, 明細走行KM = t01.走行KM == null ? 0 : t01.走行KM, 備考 = t01.請求摘要, }).AsQueryable(); if (!(string.IsNullOrEmpty(p乗務員From + p乗務員To) && i乗務員List.Length == 0)) { //乗務員が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p乗務員From + p乗務員To)) { query = query.Where(c => c.乗務員コード >= int.MaxValue); } //乗務員From処理 Min値 if (!string.IsNullOrEmpty(p乗務員From)) { int i乗務員FROM = AppCommon.IntParse(p乗務員From); query = query.Where(c => c.乗務員コード >= i乗務員FROM); } //乗務員To処理 Max値 if (!string.IsNullOrEmpty(p乗務員To)) { int i乗務員TO = AppCommon.IntParse(p乗務員To); query = query.Where(c => c.乗務員コード <= i乗務員TO); } if (i乗務員List.Length > 0) { var intCause = i乗務員List; query = query.Union(from m04 in context.M04_DRV from t01 in context.T01_TRN.Where(t01 => m04.乗務員KEY == t01.乗務員KEY && (t01.配送日付 >= d集計期間From && t01.配送日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01Group from m01G in m01Group join m05 in context.M05_CAR on t01.車輌KEY equals m05.車輌KEY into m05Group from m05G in m05Group where intCause.Contains(m04.乗務員ID) && m04.削除日付 == null select new DLY19010_Member { 車輌コード = m05G.車輌ID, 乗務員コード = m04.乗務員ID, 日付 = t01.配送日付, 車番 = t01.車輌番号, 乗務員名 = m04.乗務員名, 得意先名 = m01G.略称名, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量, 重量 = t01.重量, 明細走行KM = t01.走行KM == null ? 0 : t01.走行KM, 備考 = t01.請求摘要, }).AsQueryable(); } else { query = query.Where(c => c.乗務員コード > int.MinValue && c.乗務員コード < int.MaxValue); } } query = query.Distinct(); var ret = query.ToList(); //レコード埋め作業 var query_2 = (from q in ret group q by new { q.日付, q.乗務員コード } into grp select new DLY19010_Member { 日付 = grp.Key.日付, 乗務員コード = grp.FirstOrDefault().乗務員コード, }).ToList(); foreach (var row in query_2) { var query_3 = (from q in ret where q.乗務員コード == row.乗務員コード && q.日付 == row.日付 select new DLY19010_Member { 日付 = row.日付, 乗務員コード = row.乗務員コード, }).ToList(); int cnt = 0; if (query_3.Count > 0) { cnt = 11 - (query_3.Count % 11); } ; for (int i = 0; i < cnt; i++) { ret.Add(new DLY19010_Member { 車輌コード = row.車輌コード, 乗務員コード = row.乗務員コード, 日付 = row.日付, 車番 = row.車番, 乗務員名 = string.Empty, 得意先名 = string.Empty, 発地名 = string.Empty, 着地名 = string.Empty, 商品名 = string.Empty, 数量 = null, 重量 = null, 明細走行KM = null, 備考 = string.Empty, }); } ; } ; ret = ret.OrderBy(c => c.乗務員コード).ThenBy(c => c.日付).ToList(); //結果 return(ret); } }
/// <summary> /// 摘要マスタ一覧検索データ取得 /// </summary> /// <returns></returns> public List <M11_TEK_Member> GetSearchDataForList(string 摘要コードFROM, string 摘要コードTO, string 摘要指定, string 表示方法) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var ret = (from m11 in context.M11_TEK where m11.削除日時 == null select new M11_TEK_Member { 摘要ID = m11.摘要ID, 登録日時 = m11.登録日時, 更新日時 = m11.最終更新日時, 摘要名 = m11.摘要名, かな読み = m11.かな読み, }).AsQueryable(); if (!(string.IsNullOrEmpty(摘要コードFROM + 摘要コードTO) && string.IsNullOrEmpty(摘要指定))) { //if (string.IsNullOrEmpty(摘要コードFROM + 摘要コードTO)) //{ // ret = ret.Where(c => c.摘要ID >= int.MaxValue); //} if (!string.IsNullOrEmpty(摘要コードFROM)) { int i摘要コードFROM = AppCommon.IntParse(摘要コードFROM); ret = ret.Where(c => c.摘要ID >= i摘要コードFROM); } if (!string.IsNullOrEmpty(摘要コードTO)) { int i摘要コードTO = AppCommon.IntParse(摘要コードTO); ret = ret.Where(c => c.摘要ID <= i摘要コードTO); } if (!string.IsNullOrEmpty(摘要指定)) { ret = ret.Where(c => c.摘要名.Contains(摘要指定)); //var intCause = i摘要IDList; //ret = ret.Union(from m11 in context.M11_TEK // where m11.削除日時 == null && intCause.Contains(m11.摘要ID) // select new M11_TEK_Member // { // 摘要ID = m11.摘要ID, // 登録日時 = m11.登録日時, // 更新日時 = m11.更新日時, // 摘要名 = m11.摘要名, // かな読み = m11.かな読み, // }); } } ret = ret.Distinct(); if (表示方法 == "0") { ret = ret.OrderBy(c => c.摘要ID); } else { ret = ret.OrderBy(c => c.かな読み); } return(ret.ToList()); } }
/// <summary> /// 得意先別車種別単価一覧表プレビュー用出力 /// 得意先別車種別単価一覧表CSV用出力 /// </summary> /// <returns></returns> /// <param name="s13drvs">S13_drvs__Member</param> public List <S13_DRV_Member_Preview_csv> GetSearchListData(string p乗務員IDFrom, string p乗務員IDTo, string p処理年月From, string p処理年月To, int[] i乗務員List) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var query = (from s13 in context.S13_DRV from m04 in context.M04_DRV.Where(m04 => m04.乗務員KEY == s13.乗務員KEY) //where s13.削除日付 == null select new S13_DRV_Member_Preview_csv { 乗務員KEY = m04.乗務員ID, 集計年月 = s13.集計年月, 登録日時 = s13.登録日時, 更新日時 = s13.更新日時, 自社部門ID = s13.自社部門ID, 車種ID = s13.車種ID, 車輌KEY = s13.車輌KEY, 営業日数 = s13.営業日数, 稼動日数 = s13.稼動日数, 走行KM = s13.走行KM, 実車KM = s13.実車KM, 輸送屯数 = s13.輸送屯数, 運送収入 = s13.運送収入, 燃料L = s13.燃料L, 一般管理費 = s13.一般管理費, 拘束時間 = s13.拘束時間, 運転時間 = s13.運転時間, 高速時間 = s13.高速時間, 作業時間 = s13.作業時間, 待機時間 = s13.待機時間, 休憩時間 = s13.休憩時間, 残業時間 = s13.残業時間, 深夜時間 = s13.深夜時間, }); if (!string.IsNullOrEmpty(p乗務員IDFrom)) { int ip乗務員IDFrom = AppCommon.IntParse(p乗務員IDFrom); query = query.Where(c => c.乗務員KEY >= ip乗務員IDFrom); } if (!string.IsNullOrEmpty(p乗務員IDTo)) { int ip乗務員IDTo = AppCommon.IntParse(p乗務員IDTo); query = query.Where(c => c.乗務員KEY <= ip乗務員IDTo); } if (!string.IsNullOrEmpty(p処理年月From)) { int ip処理年月From = AppCommon.IntParse(p処理年月From); query = query.Where(c => c.集計年月 >= ip処理年月From); } if (!string.IsNullOrEmpty(p処理年月To)) { int ip処理年月To = AppCommon.IntParse(p処理年月To); query = query.Where(c => c.集計年月 <= ip処理年月To); } if (i乗務員List.Length > 0) { var intCause = i乗務員List; query = query.Union(from s13 in context.S13_DRV from m04 in context.M04_DRV.Where(m04 => m04.乗務員KEY == s13.乗務員KEY) where intCause.Contains(m04.乗務員KEY) select new S13_DRV_Member_Preview_csv { 乗務員KEY = m04.乗務員ID, 集計年月 = s13.集計年月, 登録日時 = s13.登録日時, 更新日時 = s13.更新日時, 自社部門ID = s13.自社部門ID, 車種ID = s13.車種ID, 車輌KEY = s13.車輌KEY, 営業日数 = s13.営業日数, 稼動日数 = s13.稼動日数, 走行KM = s13.走行KM, 実車KM = s13.実車KM, 輸送屯数 = s13.輸送屯数, 運送収入 = s13.運送収入, 燃料L = s13.燃料L, 一般管理費 = s13.一般管理費, 拘束時間 = s13.拘束時間, 運転時間 = s13.運転時間, 高速時間 = s13.高速時間, 作業時間 = s13.作業時間, 待機時間 = s13.待機時間, 休憩時間 = s13.休憩時間, 残業時間 = s13.残業時間, 深夜時間 = s13.深夜時間, }); } //削除データ検索条件 query = query.OrderBy(c => (c.乗務員KEY)); return(query.ToList()); } }
public List <SRY09010_Member> SRY09010_GetDataHinList(string s車輌From, string s車輌To, int?[] i車輌List, string p集計期間From, string p集計期間To, int i表示順序) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { string s集計期間From, s集計期間To; s集計期間From = p集計期間From.ToString().Substring(0, 4) + "年" + p集計期間From.ToString().Substring(4, 2) + "月度"; s集計期間To = p集計期間To.ToString().Substring(0, 4) + "年" + p集計期間To.ToString().Substring(4, 2) + "月度"; int i集計期間From, i集計期間To; i集計期間From = Convert.ToInt32(p集計期間From); i集計期間To = Convert.ToInt32(p集計期間To); List <SRY09010_Member> retList = new List <SRY09010_Member>(); context.Connection.Open(); try { string 車輌ピックアップ指定 = string.Empty; var goukei = (from s14c in context.S14_CARSB where s14c.集計年月 >= i集計期間From && s14c.集計年月 <= i集計期間To group s14c by s14c.車輌KEY into Group select new SRY09010g_Member { 車輌Key = Group.Key, 合計 = Group.Sum(c => c.金額), }).AsQueryable(); var query = (from m05 in context.M05_CAR.Where(c => c.削除日付 == null) join s14 in context.S14_CAR.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m05.車輌KEY equals s14.車輌KEY into Group from s14Group in Group join s14g in goukei on s14Group.車輌KEY equals s14g.車輌Key into sg14Group from sgg14Group in sg14Group group new { m05, s14Group, sgg14Group } by new { m05.車輌ID, m05.車輌番号, sgg14Group.合計 } into grGroup select new SRY09010_Member { 車輌ID = grGroup.Key.車輌ID, 車輌番号 = grGroup.Key.車輌番号, 日数 = grGroup.Sum(c => c.s14Group.稼動日数) == null ? 0 : grGroup.Sum(c => c.s14Group.稼動日数), 拘束H = grGroup.Sum(c => c.s14Group.拘束時間) == null ? 0 : grGroup.Sum(c => c.s14Group.拘束時間), 運転H = grGroup.Sum(c => c.s14Group.運転時間) == null ? 0 : grGroup.Sum(c => c.s14Group.運転時間), 高速H = grGroup.Sum(c => c.s14Group.高速時間) == null ? 0 : grGroup.Sum(c => c.s14Group.高速時間), 作業H = grGroup.Sum(c => c.s14Group.作業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.作業時間), 休憩H = grGroup.Sum(c => c.s14Group.休憩時間) == null ? 0 : grGroup.Sum(c => c.s14Group.休憩時間), 残業H = grGroup.Sum(c => c.s14Group.残業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.残業時間), 深夜H = grGroup.Sum(c => c.s14Group.深夜時間) == null ? 0 : grGroup.Sum(c => c.s14Group.深夜時間), 走行KM = grGroup.Sum(c => c.s14Group.走行KM) == null ? 0 : grGroup.Sum(c => c.s14Group.走行KM), 実車KM = grGroup.Sum(c => c.s14Group.実車KM) == null ? 0 : grGroup.Sum(c => c.s14Group.実車KM), 輸送屯数 = grGroup.Sum(c => c.s14Group.輸送屯数) == null ? 0 : grGroup.Sum(c => c.s14Group.輸送屯数), 運送収入 = grGroup.Sum(c => c.s14Group.運送収入) == null ? 0 : grGroup.Sum(c => c.s14Group.運送収入), 燃料L = grGroup.Sum(c => c.s14Group.燃料L) == null ? 0 : grGroup.Sum(c => c.s14Group.燃料L), 経費合計 = grGroup.Key.合計, 集計年月From = s集計期間From, 集計年月To = s集計期間To, 表示順序 = i表示順序 == 0 ? "ID順" : i表示順序 == 1 ? "車種順" : "運送収入順", 車輌指定 = s車輌From + "~" + s車輌To, 車輌ピックアップ = 車輌ピックアップ指定 == "" ? "無" : 車輌ピックアップ指定, }).AsQueryable(); //***検索条件***// if (!(string.IsNullOrEmpty(s車輌From + s車輌To) && i車輌List.Length == 0)) { //From & ToがNULLだった場合 if (string.IsNullOrEmpty(s車輌From + s車輌To)) { query = query.Where(c => c.車輌ID >= int.MaxValue); } //車輌From処理 Min値 if (!string.IsNullOrEmpty(s車輌From)) { int i車輌From = AppCommon.IntParse(s車輌From); query = query.Where(c => c.車輌ID >= i車輌From); } //車輌To処理 Max値 if (!string.IsNullOrEmpty(s車輌To)) { int i車輌TO = AppCommon.IntParse(s車輌To); query = query.Where(c => c.車輌ID <= i車輌TO); } if (i車輌List.Length > 0) { var intCause = i車輌List; query = query.Union(from m05 in context.M05_CAR.Where(c => c.削除日付 == null) join s14 in context.S14_CAR.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m05.車輌KEY equals s14.車輌KEY into Group from s14Group in Group join s14g in goukei on s14Group.車輌KEY equals s14g.車輌Key into sg14Group from sgg14Group in sg14Group group new { m05, s14Group, sgg14Group } by new { m05.車輌ID, m05.車輌番号, sgg14Group.合計 } into grGroup where intCause.Contains(grGroup.Key.車輌ID) select new SRY09010_Member { 車輌ID = grGroup.Key.車輌ID, 車輌番号 = grGroup.Key.車輌番号, 日数 = grGroup.Sum(c => c.s14Group.稼動日数) == null ? 0 : grGroup.Sum(c => c.s14Group.稼動日数), 拘束H = grGroup.Sum(c => c.s14Group.拘束時間) == null ? 0 : grGroup.Sum(c => c.s14Group.拘束時間), 運転H = grGroup.Sum(c => c.s14Group.運転時間) == null ? 0 : grGroup.Sum(c => c.s14Group.運転時間), 高速H = grGroup.Sum(c => c.s14Group.高速時間) == null ? 0 : grGroup.Sum(c => c.s14Group.高速時間), 作業H = grGroup.Sum(c => c.s14Group.作業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.作業時間), 休憩H = grGroup.Sum(c => c.s14Group.休憩時間) == null ? 0 : grGroup.Sum(c => c.s14Group.休憩時間), 残業H = grGroup.Sum(c => c.s14Group.残業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.残業時間), 深夜H = grGroup.Sum(c => c.s14Group.深夜時間) == null ? 0 : grGroup.Sum(c => c.s14Group.深夜時間), 走行KM = grGroup.Sum(c => c.s14Group.走行KM) == null ? 0 : grGroup.Sum(c => c.s14Group.走行KM), 実車KM = grGroup.Sum(c => c.s14Group.実車KM) == null ? 0 : grGroup.Sum(c => c.s14Group.実車KM), 輸送屯数 = grGroup.Sum(c => c.s14Group.輸送屯数) == null ? 0 : grGroup.Sum(c => c.s14Group.輸送屯数), 運送収入 = grGroup.Sum(c => c.s14Group.運送収入) == null ? 0 : grGroup.Sum(c => c.s14Group.運送収入), 燃料L = grGroup.Sum(c => c.s14Group.燃料L) == null ? 0 : grGroup.Sum(c => c.s14Group.燃料L), 経費合計 = grGroup.Key.合計, 集計年月From = s集計期間From, 集計年月To = s集計期間To, 表示順序 = i表示順序 == 0 ? "ID順" : i表示順序 == 1 ? "車種順" : "運送収入順", 車輌指定 = s車輌From + "~" + s車輌To, 車輌ピックアップ = 車輌ピックアップ指定 == "" ? "無" : 車輌ピックアップ指定, }); } } else { //車輌FromがNullだった場合 if (string.IsNullOrEmpty(s車輌From)) { query = query.Where(c => c.車輌ID >= int.MinValue); } //車輌ToがNullだった場合 if (string.IsNullOrEmpty(s車輌To)) { query = query.Where(c => c.車輌ID <= int.MaxValue); } } //乗務員指定の表示 if (i車輌List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 車輌ピックアップ指定 = 車輌ピックアップ指定 + i車輌List[i].ToString(); if (i < i車輌List.Length) { if (i == i車輌List.Length - 1) { break; } 車輌ピックアップ指定 = 車輌ピックアップ指定 + ","; } if (i車輌List.Length == 1) { break; } } } //表示順序変更 switch (i表示順序) { case 0: //車輌番号昇順 query = query.OrderBy(c => c.車輌ID); break; case 1: query = query.OrderBy(c => c.車輌番号); break; case 2: //運送収入降順 query = query.OrderByDescending(c => c.運送収入); break; } query = query.Where(c => c.経費合計 != 0 || c.日数 != 0 || c.運送収入 != 0); //retList = query.ToList(); foreach (var rec in query) { // 各時間項目の時分を、分に変換する。 rec.拘束H = (decimal)LinqSub.時間TO分(rec.拘束H); rec.運転H = (decimal)LinqSub.時間TO分(rec.運転H); rec.高速H = (decimal)LinqSub.時間TO分(rec.高速H); rec.作業H = (decimal)LinqSub.時間TO分(rec.作業H); //rec.待機H = (decimal)LinqSub.時間TO分(rec.待機H); rec.休憩H = (decimal)LinqSub.時間TO分(rec.休憩H); rec.残業H = (decimal)LinqSub.時間TO分(rec.残業H); rec.深夜H = (decimal)LinqSub.時間TO分(rec.深夜H); retList.Add(rec); } return(retList); } catch (Exception ex) { throw ex; } } }
/// <summary> /// 得意先別車種別単価一覧表プレビュー用出力 /// 得意先別車種別単価一覧表CSV用出力 /// </summary> /// <returns></returns> /// <param name="s11tokg">S11_toks__Member</param> public List <S11_TOKG_Member_Preview_csv> GetSearchListData(string p得意先IDFrom, string p得意先IDTo, string p処理年月From, string p処理年月To, string p回数From, string p回数To, int[] i得意先List) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); var query = (from s11 in context.S11_TOKG from m01 in context.M01_TOK.Where(m01 => m01.得意先KEY == s11.得意先KEY) //where s11.削除日付 == null select new S11_TOKG_Member_Preview_csv { 得意先KEY = m01.得意先ID, 得意先名 = m01.略称名, 集計年月 = s11.集計年月, 回数 = s11.回数, 月集計開始日 = s11.月集計開始日, 月集計終了日 = s11.月集計終了日, 月次前月残高 = s11.月次前月残高, 月次入金現金 = s11.月次入金手形, 月次入金手形 = s11.月次入金手形, 月次入金その他 = s11.月次入金その他, 月次売上金額 = s11.月次売上金額, 月次通行料 = s11.月次通行料, 月次非課税売上 = s11.月次非課税売上, 月次課税売上 = s11.月次課税売上, 月次消費税 = s11.月次消費税, 月次内傭車売上 = s11.月次内傭車売上, 月次内傭車料 = s11.月次内傭車料, 月次未定件数 = s11.月次未定件数, 月次件数 = s11.月次件数, }); if (!string.IsNullOrEmpty(p得意先IDFrom)) { int ip得意先IDFrom = AppCommon.IntParse(p得意先IDFrom); query = query.Where(c => c.得意先KEY >= ip得意先IDFrom); } if (!string.IsNullOrEmpty(p得意先IDTo)) { int ip得意先IDTo = AppCommon.IntParse(p得意先IDTo); query = query.Where(c => c.得意先KEY <= ip得意先IDTo); } if (!string.IsNullOrEmpty(p処理年月From)) { int ip処理年月From = AppCommon.IntParse(p処理年月From); query = query.Where(c => c.集計年月 >= ip処理年月From); } if (!string.IsNullOrEmpty(p処理年月To)) { int ip処理年月To = AppCommon.IntParse(p処理年月To); query = query.Where(c => c.集計年月 <= ip処理年月To); } if (!string.IsNullOrEmpty(p回数From)) { int ip回数From = AppCommon.IntParse(p回数From); query = query.Where(c => c.回数 >= ip回数From); } if (!string.IsNullOrEmpty(p回数To)) { int ip回数To = AppCommon.IntParse(p回数To); query = query.Where(c => c.集計年月 <= ip回数To); } if (i得意先List.Length > 0) { var intCause = i得意先List; query = query.Union(from s11 in context.S11_TOKG from m01 in context.M01_TOK.Where(m01 => m01.得意先KEY == s11.得意先KEY) where intCause.Contains(m01.得意先KEY) select new S11_TOKG_Member_Preview_csv { 得意先KEY = m01.得意先ID, 得意先名 = m01.略称名, 集計年月 = s11.集計年月, 回数 = s11.回数, 月集計開始日 = s11.月集計開始日, 月集計終了日 = s11.月集計終了日, 月次前月残高 = s11.月次前月残高, 月次入金現金 = s11.月次入金手形, 月次入金手形 = s11.月次入金手形, 月次入金その他 = s11.月次入金その他, 月次売上金額 = s11.月次売上金額, 月次通行料 = s11.月次通行料, 月次非課税売上 = s11.月次非課税売上, 月次課税売上 = s11.月次課税売上, 月次消費税 = s11.月次消費税, 月次内傭車売上 = s11.月次内傭車売上, 月次内傭車料 = s11.月次内傭車料, 月次未定件数 = s11.月次未定件数, 月次件数 = s11.月次件数, }); } //削除データ検索条件 query = query.OrderBy(c => (c.得意先KEY)); return(query.ToList()); } }
////<summary> ////SHR08010 印刷 支払一覧表 ////</summary> ////<param name="p商品ID">支払先コード</param> ////<returns>T01</returns> public List <SHR08010_Member> SHR08010_GetDataHinList2(string p支払先From, string p支払先To, int?[] i支払先List, string p作成締日, bool 全締日集計, int i集計年月, int i集計区分, int i表示区分, string i作成年, string i作成月, int i表示順序) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { string 支払先指定ピックアップ = string.Empty; List <SHR08010_Member> retList = new List <SHR08010_Member>(); context.Connection.Open(); var query = (from m01 in context.M01_TOK join s12 in context.S12_YOSG.Where(c => c.集計年月 == i集計年月 && c.回数 == 1) on m01.得意先KEY equals s12.支払先KEY into Group where m01.削除日付 == null select new SHR08010_Member { 支払先コード = m01.得意先ID, 支払先名 = m01.略称名, 会社名カナ = m01.かな読み, 親子区分名 = m01.親子区分ID == 0 ? "" : m01.親子区分ID == 1 ? "親" : m01.親子区分ID == 2 ? "親" : "子", 締日 = m01.S締日, 前月残高 = Group.Sum(c => c.月次前月残高), 出金金額 = Group.Sum(c => c.月次入金現金 + c.月次入金手形), 出金調整額 = Group.Sum(c => c.月次入金その他), 差引金額 = Group.Sum(c => (c.月次前月残高) - (c.月次入金現金 + c.月次入金手形 + c.月次入金その他)), 当月支払 = Group.Sum(c => c.月次売上金額), 内課税額 = Group.Sum(c => c.月次課税売上), 消費税 = Group.Sum(c => c.月次消費税), 通行料 = Group.Sum(c => c.月次通行料), 当月合計額 = Group.Sum(c => c.月次売上金額 + c.月次通行料 + c.月次消費税), 繰越金額 = Group.Sum(c => ((c.月次前月残高) - (c.月次入金現金 + c.月次入金手形 + c.月次入金その他)) + (c.月次売上金額 + c.月次通行料 + c.月次消費税)), 件数 = Group.Sum(c => c.月次件数), 作成年月 = i作成年 + "年" + i作成月 + "年度", 支払先指定 = p支払先From + "~" + p支払先To, 未定 = Group.Count(c => c.月次未定件数 > 0) != 0 ? "未定" : "", 集計区分 = i集計区分 == 0 ? "(締日データを集計)" : "(月次データを集計)", 表示区分 = i表示区分 == 0 ? "(支払あり支払先のみ)" : "(支払無し支払先含む)", 表示締日 = 全締日集計 == true ? "全締日" : p作成締日, 表示順序 = i表示順序 == 0 ? "支払先ID" : i表示順序 == 1 ? "カナ読み" : i表示順序 == 2 ? "前月残高" : i表示順序 == 3 ? "当月支払" : "繰越金額", 支払先ピックアップ = 支払先指定ピックアップ == "" ? "" : 支払先指定ピックアップ, }).AsQueryable(); //***検索条件***// if (!(string.IsNullOrEmpty(p支払先From + p支払先To) && i支払先List.Length == 0)) { //From & ToがNULLだった場合 if (string.IsNullOrEmpty(p支払先From + p支払先To)) { query = query.Where(c => c.支払先コード >= int.MaxValue); } //支払先From処理 Min値 if (!string.IsNullOrEmpty(p支払先From)) { int i支払先FROM = AppCommon.IntParse(p支払先From); query = query.Where(c => c.支払先コード >= i支払先FROM); } //支払先To処理 Max値 if (!string.IsNullOrEmpty(p支払先To)) { int i支払先TO = AppCommon.IntParse(p支払先To); query = query.Where(c => c.支払先コード <= i支払先TO); } //締日処理 if (全締日集計 == true) { query = query.Where(c => c.締日 >= 1 && c.締日 <= 31); } else { int i作成締日 = AppCommon.IntParse(p作成締日); query = query.Where(c => c.締日 == i作成締日); } if (i支払先List.Length > 0) { var intCause = i支払先List; query = query.Union(from m01 in context.M01_TOK join s12 in context.S12_YOSG.Where(c => c.集計年月 == i集計年月 && c.回数 == 1) on m01.得意先KEY equals s12.支払先KEY into Group where m01.削除日付 == null && intCause.Contains(m01.得意先ID) select new SHR08010_Member { 支払先コード = m01.得意先ID, 支払先名 = m01.略称名, 会社名カナ = m01.かな読み, 親子区分名 = m01.親子区分ID == 0 ? "" : m01.親子区分ID == 1 ? "親" : m01.親子区分ID == 2 ? "親" : "子", 締日 = m01.S締日, 前月残高 = Group.Sum(c => c.月次前月残高), 出金金額 = Group.Sum(c => c.月次入金現金 + c.月次入金手形), 出金調整額 = Group.Sum(c => c.月次入金その他), 差引金額 = Group.Sum(c => (c.月次前月残高) - (c.月次入金現金 + c.月次入金手形 + c.月次入金その他)), 当月支払 = Group.Sum(c => c.月次売上金額), 内課税額 = Group.Sum(c => c.月次課税売上), 消費税 = Group.Sum(c => c.月次消費税), 通行料 = Group.Sum(c => c.月次通行料), 当月合計額 = Group.Sum(c => c.月次売上金額 + c.月次通行料 + c.月次消費税), 繰越金額 = Group.Sum(c => ((c.月次前月残高) - (c.月次入金現金 + c.月次入金手形 + c.月次入金その他)) + (c.月次売上金額 + c.月次通行料 + c.月次消費税)), 件数 = Group.Sum(c => c.月次件数), 作成年月 = i作成年 + "年" + i作成月 + "年度", 支払先指定 = p支払先From + "~" + p支払先To, 未定 = Group.Count(c => c.月次未定件数 > 0) != 0 ? "未定" : "", 集計区分 = i集計区分 == 0 ? "(締日データを集計)" : "(月次データを集計)", 表示区分 = i表示区分 == 0 ? "(支払あり支払先のみ)" : "(支払無し支払先含む)", 表示締日 = 全締日集計 == true ? "全締日" : p作成締日, 表示順序 = i表示順序 == 0 ? "支払先ID" : i表示順序 == 1 ? "カナ読み" : i表示順序 == 2 ? "前月残高" : i表示順序 == 3 ? "当月支払" : "繰越金額", 支払先ピックアップ = 支払先指定ピックアップ == "" ? "" : 支払先指定ピックアップ, }).AsQueryable(); } } else { //支払先From処理 Min値 if (!string.IsNullOrEmpty(p支払先From)) { int i支払先FROM = AppCommon.IntParse(p支払先From); query = query.Where(c => c.支払先コード >= int.MinValue); } //支払先To処理 Max値 if (!string.IsNullOrEmpty(p支払先To)) { int i支払先TO = AppCommon.IntParse(p支払先To); query = query.Where(c => c.支払先コード <= int.MaxValue); } //締日処理 if (全締日集計 == true) { query = query.Where(c => c.締日 >= 1 && c.締日 <= 31); } else { int i作成締日 = AppCommon.IntParse(p作成締日); query = query.Where(c => c.締日 == i作成締日); } } //支払先指定の表示 if (i支払先List.Length > 0) { for (int Count = 0; Count < query.Count(); Count++) { 支払先指定ピックアップ = 支払先指定ピックアップ + i支払先List[Count].ToString(); if (Count < i支払先List.Length) { if (Count == i支払先List.Length - 1) { break; } 支払先指定ピックアップ = 支払先指定ピックアップ + ","; } if (i支払先List.Length == 1) { break; } } } switch (i表示区分) { //支払取引全体 case 0: query = query.Where(c => c.当月支払 != 0 || c.前月残高 != 0); break; //支払先 case 1: query = query.Where(c => c.当月支払 != 0); break; default: break; } //表示順序1 switch (i表示順序) { case 0: //支払先コード query = query.OrderBy(order => order.支払先コード); break; case 1: //会社名カナ query = query.OrderBy(order => order.会社名カナ); break; case 2: //前月残高 query = query.OrderByDescending(order => order.前月残高); break; case 3: //当月支払 query = query.OrderByDescending(order => order.当月支払); break; case 4: //繰越金額 query = query.OrderByDescending(order => order.繰越金額); break; } retList = query.Where(c => c.支払先コード > 0).ToList(); return(retList); } }
/// <summary> /// SRY01010 印刷 /// </summary> /// <param name="p商品ID">車輌コード</param> /// <returns>T01</returns> public List <SRY01010_Member_CSV> GetDataList_CSV(string p車輌From, string p車輌To, int?[] i車輌List, int p作成締日, DateTime d集計期間From, DateTime d集計期間To, string p作成年度, string sIDList) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <SRY01010_Member_CSV> retList = new List <SRY01010_Member_CSV>(); context.Connection.Open(); var query = (from t02 in context.T02_UTRN.Where(t02 => t02.労務日 >= d集計期間From && t02.労務日 <= d集計期間To) join t03 in context.T03_KTRN on t02.明細番号 equals t03.明細番号 into t03Group join t01 in context.T01_TRN.Where(t01 => (t01.入力区分 != 3) || (t01.入力区分 == 3 && t01.明細行 != 1)) on t02.明細番号 equals t01.明細番号 into t01Group join m04 in context.M04_DRV on t02.乗務員KEY equals m04.乗務員KEY into m04Group from m04g in m04Group.DefaultIfEmpty() join m78 in context.M78_SYK on t02.出勤区分ID equals m78.出勤区分ID into m78Group from m78g in m78Group.DefaultIfEmpty() join m05 in context.M05_CAR on t02.車輌KEY equals m05.車輌KEY into m05Group from m05g in m05Group.DefaultIfEmpty() where m05g.車輌KEY != null select new SRY01010_Member_CSV { 出庫日 = t02.実運行日開始, 帰庫日 = t02.実運行日終了, 出庫H = t02.出庫時間, 帰庫H = t02.帰庫時間, 乗務員名 = m04g.乗務員名, 出庫区分 = m78g.出勤区分名, 水揚金額 = t01Group.Sum(s => s.水揚金額), 経費1 = t03Group.Where(w => w.経費項目ID == 601).Sum(s => s.金額), 経費2 = t03Group.Where(w => w.経費項目ID == 602).Sum(s => s.金額), 経費3 = t03Group.Where(w => w.経費項目ID == 603).Sum(s => s.金額), 経費4 = t03Group.Where(w => w.経費項目ID == 604).Sum(s => s.金額), 経費5 = t03Group.Where(w => w.経費項目ID == 605).Sum(s => s.金額), 経費6 = t03Group.Where(w => w.経費項目ID == 606).Sum(s => s.金額), 経費7 = t03Group.Where(w => w.経費項目ID == 607).Sum(s => s.金額), その他経費 = t03Group.Where(w => w.経費項目ID != 601 && w.経費項目ID != 602 && w.経費項目ID != 603 && w.経費項目ID != 604 && w.経費項目ID != 605 && w.経費項目ID != 606 && w.経費項目ID != 607 && w.経費項目ID != 401).Sum(s => s.金額), 拘束H = t02.拘束時間, 運転H = t02.運転時間, 高速H = t02.高速時間, 作業H = t02.作業時間, 待機H = t02.待機時間, 休憩H = t02.休憩時間, 残業H = t02.残業時間, 深夜H = t02.深夜時間, 燃料L数 = t03Group.Where(w => w.経費項目ID == 401).Sum(s => s.数量), 燃料代 = t03Group.Where(w => w.経費項目ID == 401).Sum(s => s.金額), 走行KM = t02.走行KM, 実車KM = t02.実車KM, 輸送屯数 = t02.輸送屯数, コード = m05g.車輌ID, 車輌番号 = m05g.車輌番号, }).AsQueryable(); if (!(string.IsNullOrEmpty(p車輌From + p車輌To) && i車輌List.Length == 0)) { //車輌が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p車輌From + p車輌To)) { query = query.Where(c => c.コード >= int.MaxValue); } //車輌From処理 Min値 if (!string.IsNullOrEmpty(p車輌From)) { int i車輌FROM = AppCommon.IntParse(p車輌From); query = query.Where(c => c.コード >= i車輌FROM); } //車輌To処理 Max値 if (!string.IsNullOrEmpty(p車輌To)) { int i車輌TO = AppCommon.IntParse(p車輌To); query = query.Where(c => c.コード <= i車輌TO); } if (i車輌List.Length > 0) { var intCause = i車輌List; query = query.Union(from t02 in context.T02_UTRN.Where(t02 => t02.労務日 >= d集計期間From && t02.労務日 <= d集計期間To && t02.車輌KEY != null) join t03 in context.T03_KTRN on t02.明細番号 equals t03.明細番号 into t03Group join t01 in context.T01_TRN.Where(t01 => (t01.入力区分 != 3) || (t01.入力区分 == 3 && t01.明細行 != 1)) on t02.明細番号 equals t01.明細番号 into t01Group join m04 in context.M04_DRV on t02.乗務員KEY equals m04.乗務員KEY into m04Group from m04g in m04Group.DefaultIfEmpty() join m78 in context.M78_SYK on t02.出勤区分ID equals m78.出勤区分ID into m78Group from m78g in m78Group.DefaultIfEmpty() join m05 in context.M05_CAR on t02.車輌KEY equals m05.車輌KEY into m05Group from m05g in m05Group.DefaultIfEmpty() where intCause.Contains(m05g.車輌ID) && m05g.車輌KEY != null select new SRY01010_Member_CSV { 出庫日 = t02.実運行日開始, 帰庫日 = t02.実運行日終了, 出庫H = t02.出庫時間, 帰庫H = t02.帰庫時間, 乗務員名 = m04g.乗務員名, 出庫区分 = m78g.出勤区分名, 水揚金額 = t01Group.Sum(s => s.水揚金額), 経費1 = t03Group.Where(w => w.経費項目ID == 601).Sum(s => s.金額), 経費2 = t03Group.Where(w => w.経費項目ID == 602).Sum(s => s.金額), 経費3 = t03Group.Where(w => w.経費項目ID == 603).Sum(s => s.金額), 経費4 = t03Group.Where(w => w.経費項目ID == 604).Sum(s => s.金額), 経費5 = t03Group.Where(w => w.経費項目ID == 605).Sum(s => s.金額), 経費6 = t03Group.Where(w => w.経費項目ID == 606).Sum(s => s.金額), 経費7 = t03Group.Where(w => w.経費項目ID == 607).Sum(s => s.金額), その他経費 = t03Group.Where(w => w.経費項目ID != 601 && w.経費項目ID != 602 && w.経費項目ID != 603 && w.経費項目ID != 604 && w.経費項目ID != 605 && w.経費項目ID != 606 && w.経費項目ID != 607 && w.経費項目ID != 401).Sum(s => s.金額), 拘束H = t02.拘束時間, 運転H = t02.運転時間, 高速H = t02.高速時間, 作業H = t02.作業時間, 待機H = t02.待機時間, 休憩H = t02.休憩時間, 残業H = t02.残業時間, 深夜H = t02.深夜時間, 燃料L数 = t03Group.Where(w => w.経費項目ID == 401).Sum(s => s.数量), 燃料代 = t03Group.Where(w => w.経費項目ID == 401).Sum(s => s.金額), 走行KM = t02.走行KM, 実車KM = t02.実車KM, 輸送屯数 = t02.輸送屯数, コード = m05g.車輌ID, 車輌番号 = m05g.車輌番号, }); ////車輌From処理 Min値 //if (!string.IsNullOrEmpty(p車輌From)) //{ // int i車輌FROM = AppCommon.IntParse(p車輌From); // query = query.Where(c => c.コード >= i車輌FROM); //} ////車輌To処理 Max値 //if (!string.IsNullOrEmpty(p車輌To)) //{ // int i車輌TO = AppCommon.IntParse(p車輌To); // query = query.Where(c => c.コード <= i車輌TO); //} //else //{ // query = query.Where(c => c.コード > int.MinValue && c.コード < int.MaxValue); //} } } query = query.Distinct(); query = query.OrderBy(c => c.コード).ThenBy(c => c.出庫日); //結果をリスト化 retList = query.ToList(); return(retList); } }
/// <summary> /// SRY04010 印刷 /// </summary> /// <param name="p商品ID">車種コード</param> /// <returns>T01</returns> public List <SRY04010_Member_CSV> GetDataList_CSV(string p車種From, string p車種To, int?[] i車種List, int p作成締日, DateTime d集計期間From, DateTime d集計期間To, string p作成年度, string s車種List) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { int syafrom = AppCommon.IntParse(p車種From) == 0 ? int.MinValue : AppCommon.IntParse(p車種From); int syato = AppCommon.IntParse(p車種To) == 0 ? int.MaxValue : AppCommon.IntParse(p車種To); if ((string.IsNullOrEmpty(p車種From + p車種To) && i車種List.Length != 0)) { syafrom = int.MaxValue; syato = int.MaxValue; } List <SRY04010_Member_CSV> retList = new List <SRY04010_Member_CSV>(); List <SRY04010_Date> retList2 = new List <SRY04010_Date>(); context.Connection.Open(); for (DateTime dDate = d集計期間From; dDate <= d集計期間To; dDate = dDate.AddDays(1)) { retList2.Add(new SRY04010_Date() { 日付 = dDate }); } //var query3 = (from m05 in context.M05_CAR // let t03l = from t03 in context.T03_KTRN.Where(t03 => t03.経費発生日 >= d集計期間From && t03.経費発生日 <= d集計期間To) select t03.車輌ID // where t03l.Contains(m05.) // select new SRY04010_CAR // { // 車種ID = m05.車種ID, // }).AsQueryable(); int[] lst; lst = (from m06 in context.M06_SYA.Where(m06 => m06.削除日付 == null) let t01l = from t01 in context.T01_TRN.Where(t01 => t01.請求日付 >= d集計期間From && t01.請求日付 <= d集計期間To) select t01.車種ID let t02l = from t02 in context.T02_UTRN.Where(t02 => t02.労務日 >= d集計期間From && t02.労務日 <= d集計期間To) select t02.車種ID where t01l.Contains(m06.車種ID) || t02l.Contains(m06.車種ID) select m06.車種ID).ToArray(); var query2 = (from t in context.T03_KTRN join m07 in context.M07_KEI on t.経費項目ID equals m07.経費項目ID join m05 in context.M05_CAR on t.車輌ID equals m05.車輌KEY into m05Group from m05g in m05Group join m06 in context.M06_SYA.Where(m06 => m06.削除日付 == null) on m05g.車種ID equals m06.車種ID into m06Group from m06g in m06Group where m07.固定変動区分 == 1 && t.経費発生日 >= d集計期間From && t.経費発生日 <= d集計期間To select new SRY04010_KTRN { 日付 = t.経費発生日, 経費項目ID = t.経費項目ID, 数量 = t.数量, 金額 = t.金額, 車種KEY = m06g.車種ID, }).AsQueryable(); int?[] lst2; lst2 = query2.Select(c => c.車種KEY).ToArray(); var query = (from retdate in retList2 from m06 in context.M06_SYA.Where(m06 => (m06.削除日付 == null) && (m06.車種ID >= syafrom && m06.車種ID <= syato || (i車種List.Contains(m06.車種ID)))) join t01 in context.T01_TRN.Where(t01 => (t01.支払日付 >= d集計期間From && t01.支払日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) on retdate.日付 equals t01.支払日付 into t01Group join t02 in context.T02_UTRN.Where(t02 => t02.労務日 >= d集計期間From && t02.労務日 <= d集計期間To) on retdate.日付 equals t02.労務日 into t02Group join t03 in query2.Where(t03 => t03.日付 >= d集計期間From && t03.日付 <= d集計期間To) on retdate.日付 equals t03.日付 into t03Group where lst.Contains(m06.車種ID) || lst2.Contains(m06.車種ID) orderby m06.車種ID, retdate.日付 select new SRY04010_Member_CSV { 日付 = retdate.日付, 社内金額 = t01Group.Where(t01gr => t01gr.車種ID == m06.車種ID && t01gr.支払日付 == retdate.日付 && t01gr.支払先KEY == null).Sum(t01gr => t01gr.支払金額 + t01gr.支払割増1 + t01gr.支払割増2 + t01gr.支払通行料) == null ? 0 : t01Group.Where(t01gr => t01gr.車種ID == m06.車種ID && t01gr.支払日付 == retdate.日付 && t01gr.支払先KEY == null).Sum(t01gr => t01gr.支払金額 + t01gr.支払割増1 + t01gr.支払割増2 + t01gr.支払通行料), 経費1 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 601).Sum(t03gr => t03gr.金額), 経費2 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 602).Sum(t03gr => t03gr.金額), 経費3 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 603).Sum(t03gr => t03gr.金額), 経費4 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 604).Sum(t03gr => t03gr.金額), 経費5 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 605).Sum(t03gr => t03gr.金額), 経費6 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 606).Sum(t03gr => t03gr.金額), 経費7 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 607).Sum(t03gr => t03gr.金額), その他経費 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && (t03gr.経費項目ID != 601 && t03gr.経費項目ID != 602 && t03gr.経費項目ID != 604 && t03gr.経費項目ID != 605 && t03gr.経費項目ID != 608 && t03gr.経費項目ID != 607 && t03gr.経費項目ID != 401)).Sum(t03gr => t03gr.金額), 燃料L数 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 401).Sum(t03gr => t03gr.数量), 燃料代 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 401).Sum(t03gr => t03gr.金額), 輸送屯数 = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.輸送屯数) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.輸送屯数), 走行KM = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.走行KM) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.走行KM), 実車KM = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.実車KM) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.実車KM), コード = m06.車種ID, 車種名 = m06.車種名, 経費名1 = context.M07_KEI.Where(q => q.経費項目ID == 601).Select(c => c.経費項目名).FirstOrDefault(), 経費名2 = context.M07_KEI.Where(q => q.経費項目ID == 602).Select(c => c.経費項目名).FirstOrDefault(), 経費名3 = context.M07_KEI.Where(q => q.経費項目ID == 603).Select(c => c.経費項目名).FirstOrDefault(), 経費名4 = context.M07_KEI.Where(q => q.経費項目ID == 604).Select(c => c.経費項目名).FirstOrDefault(), 経費名5 = context.M07_KEI.Where(q => q.経費項目ID == 605).Select(c => c.経費項目名).FirstOrDefault(), 経費名6 = context.M07_KEI.Where(q => q.経費項目ID == 606).Select(c => c.経費項目名).FirstOrDefault(), 経費名7 = context.M07_KEI.Where(q => q.経費項目ID == 607).Select(c => c.経費項目名).FirstOrDefault(), }).AsQueryable().Distinct(); //if (!(string.IsNullOrEmpty(p車種From + p車種To) && i車種List.Length == 0)) //{ // //車種が検索対象に入っていない時全データ取得 // if (string.IsNullOrEmpty(p車種From + p車種To)) // { // query = query.Where(c => c.コード >= int.MaxValue); // } // //車種From処理 Min値 // if (!string.IsNullOrEmpty(p車種From)) // { // int i車種FROM = AppCommon.IntParse(p車種From); // query = query.Where(c => c.コード >= i車種FROM); // } // //車種To処理 Max値 // if (!string.IsNullOrEmpty(p車種To)) // { // int i車種TO = AppCommon.IntParse(p車種To); // query = query.Where(c => c.コード <= i車種TO); // } // if (i車種List.Length > 0) // { // var intCause = i車種List; // query = query.Union(from retdate in retList2 // from m06 in context.M06_SYA.Where(m06 => m06.削除日付 == null) // join t01 in context.T01_TRN.Where(t01 => (t01.支払日付 >= d集計期間From && t01.支払日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) on retdate.日付 equals t01.支払日付 into t01Group // join t02 in context.T02_UTRN.Where(t02 => t02.労務日 >= d集計期間From && t02.労務日 <= d集計期間To) on retdate.日付 equals t02.労務日 into t02Group // join t03 in query2.Where(t03 => t03.日付 >= d集計期間From && t03.日付 <= d集計期間To) on retdate.日付 equals t03.日付 into t03Group // where lst.Contains(m06.車種ID) || lst2.Contains(m06.車種ID) // orderby m06.車種ID, retdate.日付 // where intCause.Contains(m06.車種ID) // orderby m06.車種ID, retdate.日付 // select new SRY04010_Member_CSV // { // 日付 = retdate.日付, // 社内金額 = t01Group.Where(t01gr => t01gr.車種ID == m06.車種ID && t01gr.支払日付 == retdate.日付 && t01gr.支払先KEY == null).Sum(t01gr => t01gr.支払金額 + t01gr.支払割増1 + t01gr.支払割増2 + t01gr.支払通行料) == null ? 0 : t01Group.Where(t01gr => t01gr.車種ID == m06.車種ID && t01gr.支払日付 == retdate.日付 && t01gr.支払先KEY == null).Sum(t01gr => t01gr.支払金額 + t01gr.支払割増1 + t01gr.支払割増2 + t01gr.支払通行料), // 経費1 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 601).Sum(t03gr => t03gr.金額), // 経費2 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 602).Sum(t03gr => t03gr.金額), // 経費3 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 603).Sum(t03gr => t03gr.金額), // 経費4 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 604).Sum(t03gr => t03gr.金額), // 経費5 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 605).Sum(t03gr => t03gr.金額), // 経費6 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 606).Sum(t03gr => t03gr.金額), // 経費7 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 607).Sum(t03gr => t03gr.金額), // その他経費 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && // (t03gr.経費項目ID != 601 && t03gr.経費項目ID != 602 && t03gr.経費項目ID != 604 && t03gr.経費項目ID != 605 && // t03gr.経費項目ID != 608 && t03gr.経費項目ID != 607 && t03gr.経費項目ID != 401)).Sum(t03gr => t03gr.金額), // 燃料L数 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 401).Sum(t03gr => t03gr.数量), // 燃料代 = t03Group.Where(t03gr => t03gr.車種KEY == m06.車種ID && t03gr.日付 == retdate.日付 && t03gr.経費項目ID == 401).Sum(t03gr => t03gr.金額), // 輸送屯数 = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.輸送屯数) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.輸送屯数), // 走行KM = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.走行KM) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.走行KM), // 実車KM = t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.実車KM) == null ? 0 : t02Group.Where(t02gr => t02gr.車種ID == m06.車種ID && t02gr.労務日 == retdate.日付).Sum(t02gr => t02gr.実車KM), // コード = m06.車種ID, // 車種名 = m06.車種名, // 経費名1 = context.M07_KEI.Where(q => q.経費項目ID == 601).Select(c => c.経費項目名).FirstOrDefault(), // 経費名2 = context.M07_KEI.Where(q => q.経費項目ID == 602).Select(c => c.経費項目名).FirstOrDefault(), // 経費名3 = context.M07_KEI.Where(q => q.経費項目ID == 603).Select(c => c.経費項目名).FirstOrDefault(), // 経費名4 = context.M07_KEI.Where(q => q.経費項目ID == 604).Select(c => c.経費項目名).FirstOrDefault(), // 経費名5 = context.M07_KEI.Where(q => q.経費項目ID == 605).Select(c => c.経費項目名).FirstOrDefault(), // 経費名6 = context.M07_KEI.Where(q => q.経費項目ID == 606).Select(c => c.経費項目名).FirstOrDefault(), // 経費名7 = context.M07_KEI.Where(q => q.経費項目ID == 607).Select(c => c.経費項目名).FirstOrDefault(), // }); // //車種From処理 Min値 // if (!string.IsNullOrEmpty(p車種From)) // { // int i車種FROM = AppCommon.IntParse(p車種From); // query = query.Where(c => c.コード >= i車種FROM); // } // //車種To処理 Max値 // if (!string.IsNullOrEmpty(p車種To)) // { // int i車種TO = AppCommon.IntParse(p車種To); // query = query.Where(c => c.コード <= i車種TO); // } // } // else // { // query = query.Where(c => c.コード > int.MinValue && c.コード < int.MaxValue); // } //} query = query.Distinct(); //結果をリスト化 retList = query.ToList(); return(retList); } }
/// <summary> /// JMI09010 印刷 /// </summary> /// <param name="p商品ID">乗務員コード</param> /// <returns>T01</returns> public List <JMI09010_Member_CSV> GetDataList_CSV(string p乗務員From, string p乗務員To, int?[] i乗務員List, int?i集計期間From, int?i集計期間To, string s乗務員List, int i部門区分, int i就労区分, int i表示順序, int i表示区分) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <JMI09010_Member_CSV> retList = new List <JMI09010_Member_CSV>(); context.Connection.Open(); DateTime?d集計期間From; DateTime?d集計期間To; DateTime result; //d集計期間From = DateTime.Parse(Convert.ToInt32(i集計期間From).ToString() + "/01/01"); if (DateTime.TryParse(Convert.ToInt32(i集計期間From).ToString() + "/01/01", out result)) { d集計期間From = result; } else { d集計期間From = null; } //d集計期間To = DateTime.Parse(Convert.ToInt32(i集計期間To).ToString() + "/12/31"); if (DateTime.TryParse(Convert.ToInt32(i集計期間To).ToString() + "/12/31", out result)) { d集計期間To = result; } else { d集計期間To = null; } var query = (from m04 in context.M04_DRV from m70 in context.M70_JIS.Where(m70 => m70.自社ID == m04.自社ID).DefaultIfEmpty() from m71 in context.M71_BUM.Where(m71 => m71.自社部門ID == m04.自社部門ID).DefaultIfEmpty() where m04.削除日付 == null select new JMI09010_Member_CSV { 免許有効日 = m04.免許有効年月日1, 乗務員ID = m04.乗務員ID, 乗務員名 = m04.乗務員名, カナ読み = m04.かな読み, 自社部門ID = m04.自社部門ID, 自社部門名 = m71.自社部門名, 事業者ID = m70.自社ID, 事業者名 = m70.自社名, 就労区分 = m04.就労区分, 期間From = d集計期間From, 期間To = d集計期間To, 表示順序 = i表示順序, }).AsQueryable(); query = query.Distinct(); if (!(string.IsNullOrEmpty(p乗務員From + p乗務員To) && i乗務員List.Length == 0)) { //乗務員が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p乗務員From + p乗務員To)) { query = query.Where(c => c.乗務員ID >= int.MaxValue); } //乗務員From処理 Min値 if (!string.IsNullOrEmpty(p乗務員From)) { int i乗務員FROM = AppCommon.IntParse(p乗務員From); query = query.Where(c => c.乗務員ID >= i乗務員FROM); } //乗務員To処理 Max値 if (!string.IsNullOrEmpty(p乗務員To)) { int i乗務員TO = AppCommon.IntParse(p乗務員To); query = query.Where(c => c.乗務員ID <= i乗務員TO); } //日付条件 if (i集計期間From != null && i集計期間To != null) { query = query.Where(c => c.免許有効日 >= d集計期間From && c.免許有効日 <= d集計期間To); } else if (i集計期間From != null) { query = query.Where(c => c.免許有効日 >= d集計期間From); } else if (i集計期間To != null) { query = query.Where(c => c.免許有効日 <= d集計期間To); } if (i乗務員List.Length > 0) { var intCause = i乗務員List; query = query.Union(from m04 in context.M04_DRV from m70 in context.M70_JIS.Where(m70 => m70.自社ID == m04.自社ID).DefaultIfEmpty() from m71 in context.M71_BUM.Where(m71 => m71.自社部門ID == m04.自社部門ID).DefaultIfEmpty() where intCause.Contains(m04.乗務員ID) && m04.削除日付 == null select new JMI09010_Member_CSV { 免許有効日 = m04.免許有効年月日1, 乗務員ID = m04.乗務員ID, 乗務員名 = m04.乗務員名, カナ読み = m04.かな読み, 自社部門ID = m04.自社部門ID, 自社部門名 = m71.自社部門名, 事業者ID = m70.自社ID, 事業者名 = m70.自社名, 就労区分 = m04.就労区分, 期間From = d集計期間From, 期間To = d集計期間To, 表示順序 = i表示順序, }); } } else { query = query.Where(c => c.乗務員ID > int.MinValue && c.乗務員ID < int.MaxValue); //日付条件 if (i集計期間From != null && i集計期間To != null) { query = query.Where(c => c.免許有効日 >= d集計期間From && c.免許有効日 <= d集計期間To); } else if (i集計期間From != null) { query = query.Where(c => c.免許有効日 >= d集計期間From); } else if (i集計期間To != null) { query = query.Where(c => c.免許有効日 <= d集計期間To); } } //就労区分 switch (i就労区分) { //全件 case 0: query = query.Where(c => c.就労区分 >= 0); break; //就労者 case 1: query = query.Where(c => c.就労区分 == 0); break; //休職者 case 2: query = query.Where(c => c.就労区分 == 1); break; //退職者 case 3: query = query.Where(c => c.就労区分 == 2); break; } //表示順序 switch (i表示順序) { case 0: query = query.OrderBy(c => c.乗務員ID); break; case 1: query = query.OrderBy(c => c.カナ読み); break; case 2: query = query.OrderBy(c => c.免許有効日); break; } //表示区分 switch (i表示区分) { case 0: break; case 1: query = query.Where(c => c.免許有効日 != null); break; } //結果をリスト化 retList = query.ToList(); return(retList); } }
/// <summary> /// 得意先毎の滞留額を取得する /// </summary> /// <param name="condition"> /// == 検索条件 == /// </param> /// <returns></returns> private long getTokGroupDeposit(TRAC3Entities context, int myCompany, string TokCd, string Eda, int ReferenceYearMonth, int T締日, int userId) { long retDeposit; long 前回滞留額 = 0; long 前々年度滞留額; long 今年度滞留額; int iTokCd = AppCommon.IntParse(TokCd); int iEda = AppCommon.IntParse(Eda); // Remarks:自社or販社の判定に必要 // 決算月を取得 var jis = context.M70_JIS .Where(w => w.削除日時 == null && w.自社コード == myCompany) .FirstOrDefault(); #region 前々年度末までの滞留額を取得 // 前々年度末の年月日を取得 int CurrentMonth = DateTime.Today.Month; DateTime dtTwoYearsBefore; // 決算月を取得、なければ3月固定 int i決算月 = jis.決算月 ?? 3; if (i決算月 < CurrentMonth) { // 決算月がシステム日付より小さい場合、1年前が前々年度になる dtTwoYearsBefore = DateTime.Today.AddYears(-1); } else { // 決算月がシステム日付より大きいまたは同じ場合、2年前が前々年度になる dtTwoYearsBefore = DateTime.Today.AddYears(-2); } DateTime dt前々年度開始日 = new DateTime(dtTwoYearsBefore.Year, i決算月, 1).AddMonths(1).AddYears(-1); DateTime dt前々年度終了日 = new DateTime(dtTwoYearsBefore.Year, i決算月, 1).AddMonths(1).AddDays(-1); // 得意先毎の滞留額を取得 T11_NYKNTR nyknTrRow = context.T11_NYKNTR.Where(w => w.得意先コード == iTokCd && w.得意先枝番 == iEda).FirstOrDefault(); if (nyknTrRow == null) { // データが存在しない場合、初回請求から滞留額を取得 前々年度滞留額 = getDeposit(context, null, dt前々年度終了日, myCompany, iTokCd, iEda); // 新規 T11_NYKNTR insRow = new T11_NYKNTR(); insRow.得意先コード = iTokCd; insRow.得意先枝番 = iEda; insRow.集計完了日 = dt前々年度終了日; insRow.入金滞留額 = 前々年度滞留額; insRow.登録者 = userId; insRow.登録日時 = DateTime.Now; insRow.最終更新者 = userId; insRow.最終更新日時 = DateTime.Now; context.T11_NYKNTR.ApplyChanges(insRow); context.SaveChanges(); } else if (nyknTrRow.集計完了日 == dt前々年度終了日) { // データが存在する場合、前々年度の初期値として使用 前々年度滞留額 = nyknTrRow.入金滞留額; } else { // 前回の入金滞留額を保持 前回滞留額 = nyknTrRow.入金滞留額; // 前回集計完了日の来月初めから前々年度までの滞留額を取得 前々年度滞留額 = getDeposit(context, nyknTrRow.集計完了日.AddDays(1), dt前々年度終了日, myCompany, iTokCd, iEda); // 滞留額を更新 nyknTrRow.集計完了日 = dt前々年度終了日; nyknTrRow.入金滞留額 = 前回滞留額 + 前々年度滞留額; nyknTrRow.最終更新者 = userId; nyknTrRow.最終更新日時 = DateTime.Now; nyknTrRow.AcceptChanges(); context.SaveChanges(); } #endregion // 前々年度終了日の来月初めから基準日までの滞留額を取得 DateTime dt今年度開始日 = dt前々年度終了日.AddDays(1); DateTime dt基準日 = new DateTime(ReferenceYearMonth / 100, ReferenceYearMonth % 100, 1).AddDays(-1); 今年度滞留額 = getDeposit(context, dt今年度開始日, dt基準日, myCompany, iTokCd, iEda); // 滞留額の合計を算出 retDeposit = 前回滞留額 + 前々年度滞留額 + 今年度滞留額; return(retDeposit); }
//DLY08010_NData /// <summary> /// 入金予定額取得 /// </summary> /// <param name="p明細番号"></param> /// <param name="p得意先ID"></param> /// <param name="p入金日付"></param> /// <returns></returns> public List <DLY08010_NData> DLY08010_GETNData(int p得意先ID, DateTime p入出金日付, int p明細番号) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); DLY08010_Member result = new DLY08010_Member(); var ret = from m01 in context.M01_TOK where m01.得意先ID == p得意先ID select m01; var qm01 = ret.FirstOrDefault(); int i得意先KEY; i得意先KEY = qm01.得意先KEY; #region 日付計算(入金予定額) //***日付計算(入金予定額)***// //得意先の締日を取得 int x締日 = qm01.T締日; int x日付 = Convert.ToInt32(p入出金日付.Day.ToString()); int xi出金日付; DateTime x入金日付, x入金予定日; //サイトの考え方 サイトが1の場合 締日が翌月でも翌月の末日までがサイトの領域になります 20160517対応 //if (x締日 < x日付) //{ // //締日が20締に対して入金日付が31日等だった場合 月に1を足して来月のデータとしてカウント // x入金日付 = p入出金日付.AddMonths(+1); // //入金予定額を求めるためにサイトを引いた集計年月を作成 // x入金予定日 = x入金日付.AddMonths(-qm01.Tサイト日); // xi出金日付 = AppCommon.IntParse(x入金予定日.Month.ToString().Length == 1 ? x入金予定日.Year.ToString() + "0" + x入金予定日.Month.ToString() : x入金予定日.Year.ToString() + x入金予定日.Month.ToString()); //} //else //{ x入金日付 = p入出金日付; //入金予定額を求めるためにサイトを引いた集計年月を作成 x入金予定日 = x入金日付.AddMonths(-qm01.Tサイト日); xi出金日付 = AppCommon.IntParse(x入金予定日.Month.ToString().Length == 1 ? x入金予定日.Year.ToString() + "0" + x入金予定日.Month.ToString() : x入金予定日.Year.ToString() + x入金予定日.Month.ToString()); //} var query = (from s01 in context.S01_TOKS where s01.得意先KEY == i得意先KEY && s01.集計年月 == xi出金日付 group s01 by s01.締日売上金額 into Group select new DLY08010_NData { 予定入金金額 = Group.Sum(c => c.締日売上金額 + c.締日消費税 + c.締日通行料) == null ? 0 : Group.Sum(c => c.締日売上金額 + c.締日消費税 + c.締日通行料) }).AsQueryable(); #endregion #region 日付計算(既入金額) //***日付計算(既入金額)***// int y締日 = qm01.T締日; int y日付 = AppCommon.IntParse(p入出金日付.Day.ToString()); DateTime y入金日付From, y入金日付To; if (y締日 < 31) { if (y締日 < y日付) { y入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + (y締日 + 1).ToString()); y入金日付To = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + 01); y入金日付To = y入金日付To.AddMonths(+1); y入金日付To = Convert.ToDateTime(y入金日付To.Year.ToString() + "/" + y入金日付To.Month + "/" + y締日.ToString()); } else { y入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.AddMonths(-1).Month.ToString() + "/" + (y締日 + 1).ToString()); y入金日付To = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + y締日.ToString()); } } else { y入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + 01); y入金日付To = y入金日付From.AddMonths(1).AddDays(-1); } var query2 = (from t04 in context.T04_NYUK where t04.取引先KEY == i得意先KEY && (t04.入出金日付 >= y入金日付From && t04.入出金日付 <= y入金日付To) && t04.明細区分 == 2 && t04.明細番号 != p明細番号 group t04 by t04.入出金金額 into Group select new DLY08010_NData { 既入金額 = Group.Sum(c => c.入出金金額) == null ? 0 : Group.Sum(c => c.入出金金額) }); #endregion #region 日付計算(入金相殺) //***日付計算(入金相殺)***// int z締日 = qm01.T締日; int z日付 = AppCommon.IntParse(p入出金日付.Day.ToString()); DateTime z入金日付From, z入金日付To; if (y締日 < 31) { if (y締日 < y日付) { z入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + (z締日 + 1).ToString()); z入金日付To = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + 01); z入金日付To = z入金日付To.AddMonths(+1); z入金日付To = Convert.ToDateTime(z入金日付To.Year.ToString() + "/" + z入金日付To.Month + "/" + z締日.ToString()); } else { z入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.AddMonths(-1).Month.ToString() + "/" + (z締日 + 1).ToString()); z入金日付To = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + z締日.ToString()); } } else { z入金日付From = Convert.ToDateTime(p入出金日付.Year.ToString() + "/" + p入出金日付.Month.ToString() + "/" + 01); z入金日付To = z入金日付From.AddMonths(1).AddDays(-1); } var query3 = (from t04 in context.T04_NYUK where t04.取引先KEY == i得意先KEY && (t04.入出金日付 >= z入金日付From && t04.入出金日付 <= z入金日付To) && t04.明細区分 == 3 && t04.入出金区分 == 5 group t04 by t04.入出金金額 into Group select new DLY08010_NData { 出金相殺 = Group.Sum(c => c.入出金金額) == null ? 0 : Group.Sum(c => c.入出金金額) }); #endregion //+++リスト化***// List <DLY08010_NData> queryList = new List <DLY08010_NData>(); //初期値をセット queryList.Add(new DLY08010_NData() { 出金相殺 = 0, 既入金額 = 0, 予定入金金額 = 0 }); List <DLY08010_NData> queryLIST1 = query.ToList(); List <DLY08010_NData> queryLIST2 = query2.ToList(); List <DLY08010_NData> queryLIST3 = query3.ToList(); int x = 0, y = 0, z = 0; //上記で求めたqueryの件数をひとつの合計金額に foreach (var row in queryLIST1) { queryList[0].予定入金金額 += queryLIST1[x].予定入金金額; x += 1; } foreach (var row in queryLIST2) { queryList[0].既入金額 += queryLIST2[y].既入金額; y += 1; } foreach (var row in queryLIST3) { queryList[0].出金相殺 += queryLIST3[z].出金相殺; z += 1; } return(queryList); } }
public List <SRY17010_Member1> SRY17010_GetDataHinList(string s車輌番号From, string s車輌番号To, int?[] i車輌ピックアップ, DateTime d集計期間From, DateTime d集計期間To, int?i自社部門ID) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { string sDate; sDate = d集計期間To.ToString(); sDate = sDate.Substring(0, 4) + "年" + sDate.Substring(5, 2) + "月度"; List <SRY17010_Member> retList = new List <SRY17010_Member>(); context.Connection.Open(); try { var query = (from m05 in context.M05_CAR join t03 in context.T03_KTRN.Where(t03 => t03.経費項目ID >= 501 && t03.経費項目ID <= 506 && // && t03.メーター != null t03.経費発生日 >= d集計期間From && t03.経費発生日 <= d集計期間To) on m05.車輌ID equals t03.車輌ID into KTRNGroup from t03Group in KTRNGroup.DefaultIfEmpty() join m06 in context.M06_SYA on m05.車種ID equals m06.車種ID into SYAGroup from m06Group in SYAGroup.DefaultIfEmpty() join m07kei in context.M07_KEI on t03Group.経費項目ID equals m07kei.経費項目ID into keiGroup from m07keiGroup in keiGroup.DefaultIfEmpty() join m07kou in context.M07_KOU on m07keiGroup.経費項目ID equals m07kou.経費項目ID into kouGroup from m07kouGroup in kouGroup.DefaultIfEmpty() where m05.削除日付 == null select new SRY17010_Member1 { 車輌コード = m05.車輌ID, 車輌番号 = t03Group.車輌番号 == null ? t03Group.車輌番号 : t03Group.車輌番号, 車輌登録番号 = m05.車輌登録番号, 車種名 = m06Group.車種名, 自社部門ID = t03Group.自社部門ID, 前回日付 = null, 経費発生日 = t03Group.経費発生日, 経費項目名 = m07keiGroup.経費項目名, 交換期間 = m07kouGroup.交換期間 == null ? 0 : m07kouGroup.交換期間, 交換距離 = m07kouGroup.交換距離 == null ? 0 : m07kouGroup.交換距離, 使用時間 = null, 次回予定日 = null, 数量 = t03Group.数量 == null ? 0 : t03Group.数量, 摘要 = t03Group.摘要名, 交換時距離 = t03Group.メーター == null ? 0 : t03Group.メーター, 次回予定距離 = m07kouGroup.交換距離 + t03Group.メーター == null ? 0 : m07kouGroup.交換距離 + t03Group.メーター, 明細No = t03Group.明細番号, 行 = t03Group.明細行, 前回交換時距離 = KTRNGroup.Where(t03 => t03.メーター != null).Max(t03 => t03.メーター) == null ? 0 : KTRNGroup.Where(t03 => t03.メーター != null).Max(t03 => t03.メーター), 経費項目ID = t03Group.経費項目ID, 開始日付 = d集計期間From, 終了日付 = d集計期間To, sDate = sDate, }).Distinct().AsQueryable(); //***検索条件***// if (!(string.IsNullOrEmpty(s車輌番号From + s車輌番号To) && i車輌ピックアップ.Length == 0)) { if (string.IsNullOrEmpty(s車輌番号From + s車輌番号To)) { query = query.Where(c => c.車輌コード >= int.MaxValue); } //車輌番号From処理 Min値 if (!string.IsNullOrEmpty(s車輌番号From)) { int i車輌番号From = AppCommon.IntParse(s車輌番号From); query = query.Where(c => c.車輌コード >= i車輌番号From); } //車輌番号To処理 Max値 if (!string.IsNullOrEmpty(s車輌番号To)) { int i車輌番号To = AppCommon.IntParse(s車輌番号To); query = query.Where(c => c.車輌コード <= i車輌番号To); } //自社部門 if (i自社部門ID != null) { //自社部門で検索 query = query.Where(c => c.自社部門ID == i自社部門ID); } else { //すべての自社部門で検索 query = query.Where(c => c.自社部門ID >= int.MinValue && c.自社部門ID <= int.MaxValue); } //支払先ピックアップ if (i車輌ピックアップ.Length > 0) { var intCause = i車輌ピックアップ; query = query.Union(from m05 in context.M05_CAR join t03 in context.T03_KTRN.Where(t03 => t03.経費項目ID >= 501 && t03.経費項目ID <= 506 && // && t03.メーター != null t03.経費発生日 >= d集計期間From && t03.経費発生日 <= d集計期間To) on m05.車輌ID equals t03.車輌ID into KTRNGroup from t03Group in KTRNGroup.DefaultIfEmpty() join m06 in context.M06_SYA on m05.車種ID equals m06.車種ID into SYAGroup from m06Group in SYAGroup.DefaultIfEmpty() join m07kei in context.M07_KEI on t03Group.経費項目ID equals m07kei.経費項目ID into keiGroup from m07keiGroup in keiGroup.DefaultIfEmpty() join m07kou in context.M07_KOU on m07keiGroup.経費項目ID equals m07kou.経費項目ID into kouGroup from m07kouGroup in kouGroup.DefaultIfEmpty() where m05.削除日付 == null && intCause.Contains(m05.車輌ID) select new SRY17010_Member1 { 車輌コード = m05.車輌ID, 車輌番号 = t03Group.車輌番号 == null ? t03Group.車輌番号 : t03Group.車輌番号, 車輌登録番号 = m05.車輌登録番号, 車種名 = m06Group.車種名, 自社部門ID = t03Group.自社部門ID, 前回日付 = null, 経費発生日 = t03Group.経費発生日, 経費項目名 = m07keiGroup.経費項目名, 交換期間 = m07kouGroup.交換期間 == null ? 0 : m07kouGroup.交換期間, 交換距離 = m07kouGroup.交換距離 == null ? 0 : m07kouGroup.交換距離, 使用時間 = null, 次回予定日 = null, 数量 = t03Group.数量 == null ? 0 : t03Group.数量, 摘要 = t03Group.摘要名, 交換時距離 = t03Group.メーター == null ? 0 : t03Group.メーター, 次回予定距離 = m07kouGroup.交換距離 + t03Group.メーター == null ? 0 : m07kouGroup.交換距離 + t03Group.メーター, 明細No = t03Group.明細番号, 行 = t03Group.明細行, 前回交換時距離 = KTRNGroup.Where(t03 => t03.メーター != null).Max(t03 => t03.メーター) == null ? 0 : KTRNGroup.Where(t03 => t03.メーター != null).Max(t03 => t03.メーター), 経費項目ID = t03Group.経費項目ID, 開始日付 = d集計期間From, 終了日付 = d集計期間To, sDate = sDate, }); if (i自社部門ID != null) { //自社部門で検索 query = query.Where(c => c.自社部門ID == i自社部門ID); } else { //すべての自社部門で検索 query = query.Where(c => c.自社部門ID >= int.MinValue && c.自社部門ID <= int.MaxValue); } } } else { //車輌番号がFrom&ToがNullだった場合 全件取得 if (string.IsNullOrEmpty(s車輌番号From + s車輌番号To)) { query = query.Where(c => c.車輌コード >= int.MinValue && c.車輌コード <= int.MaxValue); } //車輌番号FromがNullだった場合 Min ~ 車輌番号To else if (string.IsNullOrEmpty(s車輌番号From)) { int i車輌番号To = AppCommon.IntParse(s車輌番号To); query = query.Where(c => c.車輌コード <= i車輌番号To); } //車輌番号ToがNullだった場合 s車輌番号From ~ Max else if (string.IsNullOrEmpty(s車輌番号To)) { int i車輌番号From = AppCommon.IntParse(s車輌番号From); query = query.Where(c => c.車輌コード >= i車輌番号From); } //自社部門 if (i自社部門ID != null) { //自社部門で検索 query = query.Where(c => c.自社部門ID == i自社部門ID); } else { //すべての自社部門で検索 query = query.Where(c => c.自社部門ID >= int.MinValue && c.自社部門ID <= int.MaxValue); } } //List<SRY17010_Member> queryLIST = new List<SRY17010_Member>(); List <SRY17010_Member1> queryLIST = query.ToList(); queryLIST = query.ToList(); int 使用時間TS = 0; for (int i = 0; i < queryLIST.Count(); i++) { if (queryLIST[i].前回日付 == null) { DateTime?前回日付 = queryLIST[i].経費発生日 - TimeSpan.Parse(queryLIST[i].交換期間.ToString()); queryLIST[i].前回日付 = 前回日付; } if (queryLIST[i].使用時間 == null) { TimeSpan TS使用時間 = Convert.ToDateTime(queryLIST[i].経費発生日) - Convert.ToDateTime(queryLIST[i].前回日付); 使用時間TS = AppCommon.IntParse(TS使用時間.Days.ToString()) * 24; queryLIST[i].使用時間 = 使用時間TS; } if (queryLIST[i].次回予定日 == null) { DateTime?次回予定日 = queryLIST[i].経費発生日 + TimeSpan.Parse(queryLIST[i].交換期間.ToString()); queryLIST[i].次回予定日 = 次回予定日; } } return(queryLIST); } catch (Exception ex) { throw ex; } } }
public List <SRY12010_Member> SRY12010_GetData_CSV(string s車種From, string s車種To, int?[] i車種List, string p集計期間From, string p集計期間To, int i表示順序) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { string s集計期間From, s集計期間To; s集計期間From = p集計期間From.ToString().Substring(0, 4) + "年" + p集計期間From.ToString().Substring(4, 2) + "月度"; s集計期間To = p集計期間To.ToString().Substring(0, 4) + "年" + p集計期間To.ToString().Substring(4, 2) + "月度"; int i集計期間From, i集計期間To; i集計期間From = Convert.ToInt32(p集計期間From); i集計期間To = Convert.ToInt32(p集計期間To); List <SRY12010_Member> retList = new List <SRY12010_Member>(); context.Connection.Open(); string 車種ピックアップ指定 = string.Empty; //車種別経費合計 var goukei = (from s14 in context.S14_CAR.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) join s14c in context.S14_CARSB.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on new { s14.車輌KEY, s14.集計年月 } equals new { s14c.車輌KEY, s14c.集計年月 } into Group from s14Group in Group group new { s14, s14Group } by s14.車種ID into Group select new SRY12010g_Member { 車種ID = Group.Key, 経費合計 = Group.Sum(c => c.s14Group.金額), }).AsQueryable(); var query = (from m06 in context.M06_SYA.Where(c => c.削除日付 == null) join s14 in context.S14_CAR.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m06.車種ID equals s14.車種ID into Group from s14Group in Group join s14g in goukei on s14Group.車種ID equals s14g.車種ID into s14gGroup from s14GGroup in s14gGroup group new { m06, s14Group, s14GGroup } by new { m06.車種ID, m06.車種名, s14GGroup.経費合計 } into grGroup select new SRY12010_Member { 車種ID = grGroup.Key.車種ID, 車種名 = grGroup.Key.車種名, 台数 = grGroup.Count(), 拘束H = grGroup.Sum(c => c.s14Group.拘束時間) == null ? 0 : grGroup.Sum(c => c.s14Group.拘束時間), 運転H = grGroup.Sum(c => c.s14Group.運転時間) == null ? 0 : grGroup.Sum(c => c.s14Group.運転時間), 高速H = grGroup.Sum(c => c.s14Group.高速時間) == null ? 0 : grGroup.Sum(c => c.s14Group.高速時間), 作業H = grGroup.Sum(c => c.s14Group.作業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.作業時間), 待機H = grGroup.Sum(c => c.s14Group.待機時間) == null ? 0 : grGroup.Sum(c => c.s14Group.待機時間), 休憩H = grGroup.Sum(c => c.s14Group.休憩時間) == null ? 0 : grGroup.Sum(c => c.s14Group.休憩時間), 残業H = grGroup.Sum(c => c.s14Group.残業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.残業時間), 深夜H = grGroup.Sum(c => c.s14Group.深夜時間) == null ? 0 : grGroup.Sum(c => c.s14Group.深夜時間), 走行KM = grGroup.Sum(c => c.s14Group.走行KM) == null ? 0 : grGroup.Sum(c => c.s14Group.走行KM), 実車KM = grGroup.Sum(c => c.s14Group.実車KM) == null ? 0 : grGroup.Sum(c => c.s14Group.実車KM), 輸送屯数 = grGroup.Sum(c => c.s14Group.輸送屯数) == null ? 0 : grGroup.Sum(c => c.s14Group.輸送屯数), 運送収入 = grGroup.Sum(c => c.s14Group.運送収入) == null ? 0 : grGroup.Sum(c => c.s14Group.運送収入), 燃料L = grGroup.Sum(c => c.s14Group.燃料L) == null ? 0 : grGroup.Sum(c => c.s14Group.燃料L), 経費合計 = grGroup.Key.経費合計, 集計年月From = s集計期間From, 集計年月To = s集計期間To, 車種指定 = s車種From + "~" + s車種To, 車種ピックアップ = 車種ピックアップ指定 == "" ? "無" : 車種ピックアップ指定, 表示順序 = i表示順序 == 0 ? "ID順" : i表示順序 == 1 ? "車種名順" : "運送収入順", }).AsQueryable(); if (!string.IsNullOrEmpty(s車種From + s車種To) && i車種List.Length == 0) { //車種Fromで絞込み if (!string.IsNullOrEmpty(s車種From)) { int i車種From = AppCommon.IntParse(s車種From); query = query.Where(c => c.車種ID >= i車種From); } //車種Toで絞込み if (!string.IsNullOrEmpty(s車種To)) { int i車種To = AppCommon.IntParse(s車種To); query = query.Where(c => c.車種ID <= i車種To); } //車種ピックアップ if (i車種List.Length > 0) { var intCause = i車種List; query = query.Union(from m06 in context.M06_SYA.Where(c => c.削除日付 == null) join s14 in context.S14_CAR.Where(c => c.集計年月 >= i集計期間From && c.集計年月 <= i集計期間To) on m06.車種ID equals s14.車種ID into Group from s14Group in Group join s14g in goukei on s14Group.車種ID equals s14g.車種ID into s14gGroup from s14GGroup in s14gGroup group new { m06, s14Group, s14GGroup } by new { m06.車種ID, m06.車種名, s14GGroup.経費合計 } into grGroup where intCause.Contains(grGroup.Key.車種ID) select new SRY12010_Member { 車種ID = grGroup.Key.車種ID, 車種名 = grGroup.Key.車種名, 台数 = grGroup.Count(), 拘束H = grGroup.Sum(c => c.s14Group.拘束時間) == null ? 0 : grGroup.Sum(c => c.s14Group.拘束時間), 運転H = grGroup.Sum(c => c.s14Group.運転時間) == null ? 0 : grGroup.Sum(c => c.s14Group.運転時間), 高速H = grGroup.Sum(c => c.s14Group.高速時間) == null ? 0 : grGroup.Sum(c => c.s14Group.高速時間), 作業H = grGroup.Sum(c => c.s14Group.作業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.作業時間), 待機H = grGroup.Sum(c => c.s14Group.待機時間) == null ? 0 : grGroup.Sum(c => c.s14Group.待機時間), 休憩H = grGroup.Sum(c => c.s14Group.休憩時間) == null ? 0 : grGroup.Sum(c => c.s14Group.休憩時間), 残業H = grGroup.Sum(c => c.s14Group.残業時間) == null ? 0 : grGroup.Sum(c => c.s14Group.残業時間), 深夜H = grGroup.Sum(c => c.s14Group.深夜時間) == null ? 0 : grGroup.Sum(c => c.s14Group.深夜時間), 走行KM = grGroup.Sum(c => c.s14Group.走行KM) == null ? 0 : grGroup.Sum(c => c.s14Group.走行KM), 実車KM = grGroup.Sum(c => c.s14Group.実車KM) == null ? 0 : grGroup.Sum(c => c.s14Group.実車KM), 輸送屯数 = grGroup.Sum(c => c.s14Group.輸送屯数) == null ? 0 : grGroup.Sum(c => c.s14Group.輸送屯数), 運送収入 = grGroup.Sum(c => c.s14Group.運送収入) == null ? 0 : grGroup.Sum(c => c.s14Group.運送収入), 燃料L = grGroup.Sum(c => c.s14Group.燃料L) == null ? 0 : grGroup.Sum(c => c.s14Group.燃料L), 経費合計 = grGroup.Key.経費合計, 集計年月From = s集計期間From, 集計年月To = s集計期間To, 表示順序 = i表示順序 == 0 ? "ID順" : i表示順序 == 1 ? "車種名順" : "運送収入順", 車種指定 = s車種From + "~" + s車種To, 車種ピックアップ = 車種ピックアップ指定 == "" ? "無" : 車種ピックアップ指定, }); } } else { //** From,To,ピックアップがNullの場合全件出力**// query = query.Where(c => c.車種ID >= int.MinValue && c.車種ID <= int.MaxValue); } //乗務員指定の表示 if (i車種List.Length > 0) { for (int i = 0; i < query.Count(); i++) { 車種ピックアップ指定 = 車種ピックアップ指定 + i車種List[i].ToString(); if (i < i車種List.Length) { if (i == i車種List.Length - 1) { break; } 車種ピックアップ指定 = 車種ピックアップ指定 + ","; } if (i車種List.Length == 1) { break; } } } //表示順序 switch (i表示順序) { case 0: //車種IDを昇順 query = query.OrderBy(c => c.車種ID); break; case 1: //車種名を昇順 query = query.OrderBy(c => c.車種名); break; case 2: //運送収入を降順 query = query.OrderByDescending(c => c.運送収入); break; } //retList = query.ToList(); foreach (var rec in query) { // 各時間項目の時分を、分に変換する。 rec.拘束H = (decimal)LinqSub.時間TO分(rec.拘束H); rec.運転H = (decimal)LinqSub.時間TO分(rec.運転H); rec.高速H = (decimal)LinqSub.時間TO分(rec.高速H); rec.作業H = (decimal)LinqSub.時間TO分(rec.作業H); rec.待機H = (decimal)LinqSub.時間TO分(rec.待機H); rec.休憩H = (decimal)LinqSub.時間TO分(rec.休憩H); rec.残業H = (decimal)LinqSub.時間TO分(rec.残業H); rec.深夜H = (decimal)LinqSub.時間TO分(rec.深夜H); retList.Add(rec); } return(retList); } }
/// <summary> /// SRY02010 印刷 /// </summary> /// <param name="p商品ID">車輌コード</param> /// <returns>T01</returns> public List <SRY02010_Member_CSV> GetDataList_CSV(string p車輌From, string p車輌To, int?[] i車輌List, int p作成締日, DateTime d集計期間From, DateTime d集計期間To, string p作成年度) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { List <SRY02010_Member_CSV> retList = new List <SRY02010_Member_CSV>(); context.Connection.Open(); var query = (from m05 in context.M05_CAR join t01 in context.T01_TRN.Where(t01 => (t01.請求日付 >= d集計期間From && t01.請求日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) on m05.車輌KEY equals t01.車輌KEY join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01group from m01G in m01group.DefaultIfEmpty() join m04 in context.M04_DRV on t01.乗務員KEY equals m04.乗務員KEY into m04group from m04G in m04group.DefaultIfEmpty() select new SRY02010_Member_CSV { 日付 = t01.請求日付, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量, 重量 = t01.重量, 売上金額 = t01.売上金額, 割増1 = t01.請求割増1, 割増2 = t01.請求割増2, 通行料 = t01.通行料, 得意先名 = m01G.略称名, 備考 = t01.請求摘要, 乗務員名 = m04G.乗務員名, コード = m05.車輌ID, 車輌番号 = m05.車輌番号, 明細番号 = t01.明細番号, 明細行 = t01.明細行, }).AsQueryable(); if (!(string.IsNullOrEmpty(p車輌From + p車輌To) && i車輌List.Length == 0)) { //車輌が検索対象に入っていない時全データ取得 if (string.IsNullOrEmpty(p車輌From + p車輌To)) { query = query.Where(c => c.コード >= int.MaxValue); } //車輌From処理 Min値 if (!string.IsNullOrEmpty(p車輌From)) { int i車輌FROM = AppCommon.IntParse(p車輌From); query = query.Where(c => c.コード >= i車輌FROM); } //車輌To処理 Max値 if (!string.IsNullOrEmpty(p車輌To)) { int i車輌TO = AppCommon.IntParse(p車輌To); query = query.Where(c => c.コード <= i車輌TO); } if (i車輌List.Length > 0) { var intCause = i車輌List; query = query.Union(from m05 in context.M05_CAR join t01 in context.T01_TRN.Where(t01 => (t01.請求日付 >= d集計期間From && t01.請求日付 <= d集計期間To) && (t01.入力区分 != 3 || (t01.入力区分 == 3 && t01.明細行 != 1))) on m05.車輌KEY equals t01.車輌KEY join m01 in context.M01_TOK on t01.得意先KEY equals m01.得意先KEY into m01group from m01G in m01group.DefaultIfEmpty() join m04 in context.M04_DRV on t01.乗務員KEY equals m04.乗務員KEY into m04group from m04G in m04group.DefaultIfEmpty() where intCause.Contains(m05.車輌ID) select new SRY02010_Member_CSV { 日付 = t01.請求日付, 発地名 = t01.発地名, 着地名 = t01.着地名, 商品名 = t01.商品名, 数量 = t01.数量, 重量 = t01.重量, 売上金額 = t01.売上金額, 割増1 = t01.請求割増1, 割増2 = t01.請求割増2, 通行料 = t01.通行料, 得意先名 = m01G.略称名, 備考 = t01.請求摘要, 乗務員名 = m04G.乗務員名, コード = m05.車輌ID, 車輌番号 = m05.車輌番号, 明細番号 = t01.明細番号, 明細行 = t01.明細行, }); ////車輌From処理 Min値 //if (!string.IsNullOrEmpty(p車輌From)) //{ // int i車輌FROM = AppCommon.IntParse(p車輌From); // query = query.Where(c => c.コード >= i車輌FROM); //} ////車輌To処理 Max値 //if (!string.IsNullOrEmpty(p車輌To)) //{ // int i車輌TO = AppCommon.IntParse(p車輌To); // query = query.Where(c => c.コード <= i車輌TO); //} //else //{ // query = query.Where(c => c.コード > int.MinValue && c.コード < int.MaxValue); //} } } query = query.Distinct(); query = query.OrderBy(c => c.コード).ThenBy(c => c.日付); //結果をリスト化 retList = query.ToList(); return(retList); } }
public List <SRY24010_Member1> SRY24010_GetData(string p車輌From, string p車輌To, int?[] p車輌List, string s車輌List, string p作成締日, DateTime[] p年月date, int[] p年月, int[] p前年年月, int[] p前月年月) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { int 年月1 = p年月[0]; int 年月2 = p年月[1]; int 年月3 = p年月[2]; int 年月4 = p年月[3]; int 年月5 = p年月[4]; int 年月6 = p年月[5]; int 年月7 = p年月[6]; int 年月8 = p年月[7]; int 年月9 = p年月[8]; int 年月10 = p年月[9]; int 年月11 = p年月[10]; int 年月12 = p年月[11]; int 前年年月1 = p前年年月[0]; int 前年年月2 = p前年年月[1]; int 前年年月3 = p前年年月[2]; int 前年年月4 = p前年年月[3]; int 前年年月5 = p前年年月[4]; int 前年年月6 = p前年年月[5]; int 前年年月7 = p前年年月[6]; int 前年年月8 = p前年年月[7]; int 前年年月9 = p前年年月[8]; int 前年年月10 = p前年年月[9]; int 前年年月11 = p前年年月[10]; int 前年年月12 = p前年年月[11]; int 前月年月1 = p前月年月[0]; int 前月年月2 = p前月年月[1]; int 前月年月3 = p前月年月[2]; int 前月年月4 = p前月年月[3]; int 前月年月5 = p前月年月[4]; int 前月年月6 = p前月年月[5]; int 前月年月7 = p前月年月[6]; int 前月年月8 = p前月年月[7]; int 前月年月9 = p前月年月[8]; int 前月年月10 = p前月年月[9]; int 前月年月11 = p前月年月[10]; int 前月年月12 = p前月年月[11]; DateTime s年月1 = p年月date[0]; DateTime s年月2 = p年月date[1]; DateTime s年月3 = p年月date[2]; DateTime s年月4 = p年月date[3]; DateTime s年月5 = p年月date[4]; DateTime s年月6 = p年月date[5]; DateTime s年月7 = p年月date[6]; DateTime s年月8 = p年月date[7]; DateTime s年月9 = p年月date[8]; DateTime s年月10 = p年月date[9]; DateTime s年月11 = p年月date[10]; DateTime s年月12 = p年月date[11]; int i年月1; int i年月2; int i年月3; int i年月4; int i年月5; int i年月6; int i年月7; int i年月8; int i年月9; int i年月10; int i年月11; int i年月12; //List<SRY24010_Member1> query = new List<SRY24010_Member1>(); context.Connection.Open(); try { #region 集計 ///総売上 var query_1 = (from m05 in context.M05_CAR.Where(q => q.削除日付 == null) join s14_1 in context.S14_CAR.Where(q => q.集計年月 == 年月1) on m05.車輌KEY equals s14_1.車輌KEY into s14Group1 from s14_1G in s14Group1.DefaultIfEmpty() join s14_2 in context.S14_CAR.Where(q => q.集計年月 == 年月2) on m05.車輌KEY equals s14_2.車輌KEY into s14Group2 from s14_2G in s14Group2.DefaultIfEmpty() join s14_3 in context.S14_CAR.Where(q => q.集計年月 == 年月3) on m05.車輌KEY equals s14_3.車輌KEY into s14Group3 from s14_3G in s14Group3.DefaultIfEmpty() join s14_4 in context.S14_CAR.Where(q => q.集計年月 == 年月4) on m05.車輌KEY equals s14_4.車輌KEY into s14Group4 from s14_4G in s14Group4.DefaultIfEmpty() join s14_5 in context.S14_CAR.Where(q => q.集計年月 == 年月5) on m05.車輌KEY equals s14_5.車輌KEY into s14Group5 from s14_5G in s14Group5.DefaultIfEmpty() join s14_6 in context.S14_CAR.Where(q => q.集計年月 == 年月6) on m05.車輌KEY equals s14_6.車輌KEY into s14Group6 from s14_6G in s14Group6.DefaultIfEmpty() join s14_7 in context.S14_CAR.Where(q => q.集計年月 == 年月7) on m05.車輌KEY equals s14_7.車輌KEY into s14Group7 from s14_7G in s14Group7.DefaultIfEmpty() join s14_8 in context.S14_CAR.Where(q => q.集計年月 == 年月8) on m05.車輌KEY equals s14_8.車輌KEY into s14Group8 from s14_8G in s14Group8.DefaultIfEmpty() join s14_9 in context.S14_CAR.Where(q => q.集計年月 == 年月9) on m05.車輌KEY equals s14_9.車輌KEY into s14Group9 from s14_9G in s14Group9.DefaultIfEmpty() join s14_10 in context.S14_CAR.Where(q => q.集計年月 == 年月10) on m05.車輌KEY equals s14_10.車輌KEY into s14Group10 from s14_10G in s14Group10.DefaultIfEmpty() join s14_11 in context.S14_CAR.Where(q => q.集計年月 == 年月11) on m05.車輌KEY equals s14_11.車輌KEY into s14Group11 from s14_11G in s14Group11.DefaultIfEmpty() join s14_12 in context.S14_CAR.Where(q => q.集計年月 == 年月12) on m05.車輌KEY equals s14_12.車輌KEY into s14Group12 from s14_12G in s14Group12.DefaultIfEmpty() //join s14_13 in context.S14_CAR.Where(q => q.集計年月 >= 年月1 && q.集計年月 <= 年月12) on m05.車輌KEY equals s14_13.車輌KEY into s14Group13 //from s14_13G in s14Group13.DefaultIfEmpty() select new SRY24010_Member1 { 順序ID = 1, 車輌ID = m05.車輌ID, 車輌名 = m05.車輌番号, 月1 = s年月1, 月2 = s年月2, 月3 = s年月3, 月4 = s年月4, 月5 = s年月5, 月6 = s年月6, 月7 = s年月7, 月8 = s年月8, 月9 = s年月9, 月10 = s年月10, 月11 = s年月11, 月12 = s年月12, 営業日数1 = s14_1G == null ? 0 : s14_1G.営業日数, 営業日数2 = s14_2G == null ? 0 : s14_2G.営業日数, 営業日数3 = s14_3G == null ? 0 : s14_3G.営業日数, 営業日数4 = s14_4G == null ? 0 : s14_4G.営業日数, 営業日数5 = s14_5G == null ? 0 : s14_5G.営業日数, 営業日数6 = s14_6G == null ? 0 : s14_6G.営業日数, 営業日数7 = s14_7G == null ? 0 : s14_7G.営業日数, 営業日数8 = s14_8G == null ? 0 : s14_8G.営業日数, 営業日数9 = s14_9G == null ? 0 : s14_9G.営業日数, 営業日数10 = s14_10G == null ? 0 : s14_10G.営業日数, 営業日数11 = s14_11G == null ? 0 : s14_11G.営業日数, 営業日数12 = s14_12G == null ? 0 : s14_12G.営業日数, //営業日数合計 = s14Group13 == null ? 0 : s14Group13.Select(c => c.営業日数).Sum(), 稼働日数1 = s14_1G.稼動日数 == null ? 0 : s14_1G.稼動日数, 稼働日数2 = s14_2G.稼動日数 == null ? 0 : s14_2G.稼動日数, 稼働日数3 = s14_3G.稼動日数 == null ? 0 : s14_3G.稼動日数, 稼働日数4 = s14_4G.稼動日数 == null ? 0 : s14_4G.稼動日数, 稼働日数5 = s14_5G.稼動日数 == null ? 0 : s14_5G.稼動日数, 稼働日数6 = s14_6G.稼動日数 == null ? 0 : s14_6G.稼動日数, 稼働日数7 = s14_7G.稼動日数 == null ? 0 : s14_7G.稼動日数, 稼働日数8 = s14_8G.稼動日数 == null ? 0 : s14_8G.稼動日数, 稼働日数9 = s14_9G.稼動日数 == null ? 0 : s14_9G.稼動日数, 稼働日数10 = s14_10G.稼動日数 == null ? 0 : s14_10G.稼動日数, 稼働日数11 = s14_11G.稼動日数 == null ? 0 : s14_11G.稼動日数, 稼働日数12 = s14_12G.稼動日数 == null ? 0 : s14_12G.稼動日数, //稼働日数合計 = s14Group13 == null ? 0 : s14Group13.Select(c => c.稼動日数).Sum(), ////一時的に日数挿入 //前年対比1 = s14_1G.稼動日数 == null ? 0 : s14_1G.稼動日数, //前年対比2 = s14Group.Where(c => c.集計年月 == 前年年月2).Select(c => c.稼動日数).FirstOrDefault(), //前年対比3 = s14Group.Where(c => c.集計年月 == 前年年月3).Select(c => c.稼動日数).FirstOrDefault(), //前年対比4 = s14Group.Where(c => c.集計年月 == 前年年月4).Select(c => c.稼動日数).FirstOrDefault(), //前年対比5 = s14Group.Where(c => c.集計年月 == 前年年月5).Select(c => c.稼動日数).FirstOrDefault(), //前年対比6 = s14Group.Where(c => c.集計年月 == 前年年月6).Select(c => c.稼動日数).FirstOrDefault(), //前年対比7 = s14Group.Where(c => c.集計年月 == 前年年月7).Select(c => c.稼動日数).FirstOrDefault(), //前年対比8 = s14Group.Where(c => c.集計年月 == 前年年月8).Select(c => c.稼動日数).FirstOrDefault(), //前年対比9 = s14Group.Where(c => c.集計年月 == 前年年月9).Select(c => c.稼動日数).FirstOrDefault(), //前年対比10 = s14Group.Where(c => c.集計年月 == 前年年月10).Select(c => c.稼動日数).FirstOrDefault(), //前年対比11 = s14Group.Where(c => c.集計年月 == 前年年月11).Select(c => c.稼動日数).FirstOrDefault(), //前年対比12 = s14Group.Where(c => c.集計年月 == 前年年月12).Select(c => c.稼動日数).FirstOrDefault(), ////一時的に日数挿入 //前月対比1 = s14Group.Where(c => c.集計年月 == 前月年月1).Select(c => c.稼動日数).FirstOrDefault(), //前月対比2 = s14Group.Where(c => c.集計年月 == 前月年月2).Select(c => c.稼動日数).FirstOrDefault(), //前月対比3 = s14Group.Where(c => c.集計年月 == 前月年月3).Select(c => c.稼動日数).FirstOrDefault(), //前月対比4 = s14Group.Where(c => c.集計年月 == 前月年月4).Select(c => c.稼動日数).FirstOrDefault(), //前月対比5 = s14Group.Where(c => c.集計年月 == 前月年月5).Select(c => c.稼動日数).FirstOrDefault(), //前月対比6 = s14Group.Where(c => c.集計年月 == 前月年月6).Select(c => c.稼動日数).FirstOrDefault(), //前月対比7 = s14Group.Where(c => c.集計年月 == 前月年月7).Select(c => c.稼動日数).FirstOrDefault(), //前月対比8 = s14Group.Where(c => c.集計年月 == 前月年月8).Select(c => c.稼動日数).FirstOrDefault(), //前月対比9 = s14Group.Where(c => c.集計年月 == 前月年月9).Select(c => c.稼動日数).FirstOrDefault(), //前月対比10 = s14Group.Where(c => c.集計年月 == 前月年月10).Select(c => c.稼動日数).FirstOrDefault(), //前月対比11 = s14Group.Where(c => c.集計年月 == 前月年月11).Select(c => c.稼動日数).FirstOrDefault(), //前月対比12 = s14Group.Where(c => c.集計年月 == 前月年月12).Select(c => c.稼動日数).FirstOrDefault(), コードFrom = p車輌From, コードTo = p車輌To, ピックアップ指定 = s車輌List, //開始日付 = 開始年月1, //終了日付 = 終了年月12, }).ToList(); var query_2 = (from m05 in context.M05_CAR.Where(q => q.削除日付 == null) join s14_1 in context.S14_CAR.Where(q => q.集計年月 == 前年年月1) on m05.車輌KEY equals s14_1.車輌KEY into s14Group1 from s14_1G in s14Group1.DefaultIfEmpty() join s14_2 in context.S14_CAR.Where(q => q.集計年月 == 前年年月2) on m05.車輌KEY equals s14_2.車輌KEY into s14Group2 from s14_2G in s14Group2.DefaultIfEmpty() join s14_3 in context.S14_CAR.Where(q => q.集計年月 == 前年年月3) on m05.車輌KEY equals s14_3.車輌KEY into s14Group3 from s14_3G in s14Group3.DefaultIfEmpty() join s14_4 in context.S14_CAR.Where(q => q.集計年月 == 前年年月4) on m05.車輌KEY equals s14_4.車輌KEY into s14Group4 from s14_4G in s14Group4.DefaultIfEmpty() join s14_5 in context.S14_CAR.Where(q => q.集計年月 == 前年年月5) on m05.車輌KEY equals s14_5.車輌KEY into s14Group5 from s14_5G in s14Group5.DefaultIfEmpty() join s14_6 in context.S14_CAR.Where(q => q.集計年月 == 前年年月6) on m05.車輌KEY equals s14_6.車輌KEY into s14Group6 from s14_6G in s14Group6.DefaultIfEmpty() join s14_7 in context.S14_CAR.Where(q => q.集計年月 == 前年年月7) on m05.車輌KEY equals s14_7.車輌KEY into s14Group7 from s14_7G in s14Group7.DefaultIfEmpty() join s14_8 in context.S14_CAR.Where(q => q.集計年月 == 前年年月8) on m05.車輌KEY equals s14_8.車輌KEY into s14Group8 from s14_8G in s14Group8.DefaultIfEmpty() join s14_9 in context.S14_CAR.Where(q => q.集計年月 == 前年年月9) on m05.車輌KEY equals s14_9.車輌KEY into s14Group9 from s14_9G in s14Group9.DefaultIfEmpty() join s14_10 in context.S14_CAR.Where(q => q.集計年月 == 前年年月10) on m05.車輌KEY equals s14_10.車輌KEY into s14Group10 from s14_10G in s14Group10.DefaultIfEmpty() join s14_11 in context.S14_CAR.Where(q => q.集計年月 == 前年年月11) on m05.車輌KEY equals s14_11.車輌KEY into s14Group11 from s14_11G in s14Group11.DefaultIfEmpty() join s14_12 in context.S14_CAR.Where(q => q.集計年月 == 前年年月12) on m05.車輌KEY equals s14_12.車輌KEY into s14Group12 from s14_12G in s14Group12.DefaultIfEmpty() // join s14_13 in context.S14_CAR.Where(q => q.集計年月 >= 前年年月1 && q.集計年月 <= 前年年月12) on m05.車輌KEY equals s14_13.車輌KEY into s14Group13 select new SRY24010_Member1 { 順序ID = 1, 車輌ID = m05.車輌ID, 車輌名 = m05.車輌番号, 月1 = s年月1, 月2 = s年月2, 月3 = s年月3, 月4 = s年月4, 月5 = s年月5, 月6 = s年月6, 月7 = s年月7, 月8 = s年月8, 月9 = s年月9, 月10 = s年月10, 月11 = s年月11, 月12 = s年月12, //一時的に日数挿入 前年対比1 = s14_1G.稼動日数 == null ? 0 : s14_1G.稼動日数, 前年対比2 = s14_2G.稼動日数 == null ? 0 : s14_2G.稼動日数, 前年対比3 = s14_3G.稼動日数 == null ? 0 : s14_3G.稼動日数, 前年対比4 = s14_4G.稼動日数 == null ? 0 : s14_4G.稼動日数, 前年対比5 = s14_5G.稼動日数 == null ? 0 : s14_5G.稼動日数, 前年対比6 = s14_6G.稼動日数 == null ? 0 : s14_6G.稼動日数, 前年対比7 = s14_7G.稼動日数 == null ? 0 : s14_7G.稼動日数, 前年対比8 = s14_8G.稼動日数 == null ? 0 : s14_8G.稼動日数, 前年対比9 = s14_9G.稼動日数 == null ? 0 : s14_9G.稼動日数, 前年対比10 = s14_10G.稼動日数 == null ? 0 : s14_10G.稼動日数, 前年対比11 = s14_11G.稼動日数 == null ? 0 : s14_11G.稼動日数, 前年対比12 = s14_12G.稼動日数 == null ? 0 : s14_12G.稼動日数, //前年対比合計 = s14Group13 == null ? 0 : s14Group13.Select(c => c.稼動日数).Sum(), コードFrom = p車輌From, コードTo = p車輌To, ピックアップ指定 = s車輌List, //開始日付 = 開始年月1, //終了日付 = 終了年月12, }).ToList(); var query_3 = (from m05 in context.M05_CAR.Where(q => q.削除日付 == null) join s14_1 in context.S14_CAR.Where(q => q.集計年月 == 前月年月1) on m05.車輌KEY equals s14_1.車輌KEY into s14Group1 from s14_1G in s14Group1.DefaultIfEmpty() join s14_2 in context.S14_CAR.Where(q => q.集計年月 == 前月年月2) on m05.車輌KEY equals s14_2.車輌KEY into s14Group2 from s14_2G in s14Group2.DefaultIfEmpty() join s14_3 in context.S14_CAR.Where(q => q.集計年月 == 前月年月3) on m05.車輌KEY equals s14_3.車輌KEY into s14Group3 from s14_3G in s14Group3.DefaultIfEmpty() join s14_4 in context.S14_CAR.Where(q => q.集計年月 == 前月年月4) on m05.車輌KEY equals s14_4.車輌KEY into s14Group4 from s14_4G in s14Group4.DefaultIfEmpty() join s14_5 in context.S14_CAR.Where(q => q.集計年月 == 前月年月5) on m05.車輌KEY equals s14_5.車輌KEY into s14Group5 from s14_5G in s14Group5.DefaultIfEmpty() join s14_6 in context.S14_CAR.Where(q => q.集計年月 == 前月年月6) on m05.車輌KEY equals s14_6.車輌KEY into s14Group6 from s14_6G in s14Group6.DefaultIfEmpty() join s14_7 in context.S14_CAR.Where(q => q.集計年月 == 前月年月7) on m05.車輌KEY equals s14_7.車輌KEY into s14Group7 from s14_7G in s14Group7.DefaultIfEmpty() join s14_8 in context.S14_CAR.Where(q => q.集計年月 == 前月年月8) on m05.車輌KEY equals s14_8.車輌KEY into s14Group8 from s14_8G in s14Group8.DefaultIfEmpty() join s14_9 in context.S14_CAR.Where(q => q.集計年月 == 前月年月9) on m05.車輌KEY equals s14_9.車輌KEY into s14Group9 from s14_9G in s14Group9.DefaultIfEmpty() join s14_10 in context.S14_CAR.Where(q => q.集計年月 == 前月年月10) on m05.車輌KEY equals s14_10.車輌KEY into s14Group10 from s14_10G in s14Group10.DefaultIfEmpty() join s14_11 in context.S14_CAR.Where(q => q.集計年月 == 前月年月11) on m05.車輌KEY equals s14_11.車輌KEY into s14Group11 from s14_11G in s14Group11.DefaultIfEmpty() join s14_12 in context.S14_CAR.Where(q => q.集計年月 == 前月年月12) on m05.車輌KEY equals s14_12.車輌KEY into s14Group12 from s14_12G in s14Group12.DefaultIfEmpty() // join s14_13 in context.S14_CAR.Where(q => q.集計年月 >= 前月年月1 && q.集計年月 <= 前月年月12) on m05.車輌KEY equals s14_13.車輌KEY into s14Group13 select new SRY24010_Member1 { 順序ID = 1, 車輌ID = m05.車輌ID, 車輌名 = m05.車輌番号, 月1 = s年月1, 月2 = s年月2, 月3 = s年月3, 月4 = s年月4, 月5 = s年月5, 月6 = s年月6, 月7 = s年月7, 月8 = s年月8, 月9 = s年月9, 月10 = s年月10, 月11 = s年月11, 月12 = s年月12, //一時的に日数挿入 前月対比1 = s14_1G.稼動日数 == null ? 0 : s14_1G.稼動日数, 前月対比2 = s14_2G.稼動日数 == null ? 0 : s14_2G.稼動日数, 前月対比3 = s14_3G.稼動日数 == null ? 0 : s14_3G.稼動日数, 前月対比4 = s14_4G.稼動日数 == null ? 0 : s14_4G.稼動日数, 前月対比5 = s14_5G.稼動日数 == null ? 0 : s14_5G.稼動日数, 前月対比6 = s14_6G.稼動日数 == null ? 0 : s14_6G.稼動日数, 前月対比7 = s14_7G.稼動日数 == null ? 0 : s14_7G.稼動日数, 前月対比8 = s14_8G.稼動日数 == null ? 0 : s14_8G.稼動日数, 前月対比9 = s14_9G.稼動日数 == null ? 0 : s14_9G.稼動日数, 前月対比10 = s14_10G.稼動日数 == null ? 0 : s14_10G.稼動日数, 前月対比11 = s14_11G.稼動日数 == null ? 0 : s14_11G.稼動日数, 前月対比12 = s14_12G.稼動日数 == null ? 0 : s14_12G.稼動日数, // 前月対比合計 = s14Group13 == null ? 0 : s14Group13.Select(c => c.稼動日数).Sum(), コードFrom = p車輌From, コードTo = p車輌To, ピックアップ指定 = s車輌List, //開始日付 = 開始年月1, //終了日付 = 終了年月12, }).ToList(); var query = (from q1 in query_1 join q2 in query_2 on q1.車輌ID equals q2.車輌ID into q2Group from q2g in q2Group.DefaultIfEmpty() join q3 in query_3 on q1.車輌ID equals q3.車輌ID into q3Group from q3g in q3Group.DefaultIfEmpty() select new SRY24010_Member1 { 順序ID = 1, 車輌ID = q1.車輌ID, 車輌名 = q1.車輌名, 月1 = q1.月1, 月2 = q1.月2, 月3 = q1.月3, 月4 = q1.月4, 月5 = q1.月5, 月6 = q1.月6, 月7 = q1.月7, 月8 = q1.月8, 月9 = q1.月9, 月10 = q1.月10, 月11 = q1.月11, 月12 = q1.月12, 営業日数1 = q1.営業日数1, 営業日数2 = q1.営業日数2, 営業日数3 = q1.営業日数3, 営業日数4 = q1.営業日数4, 営業日数5 = q1.営業日数5, 営業日数6 = q1.営業日数6, 営業日数7 = q1.営業日数7, 営業日数8 = q1.営業日数8, 営業日数9 = q1.営業日数9, 営業日数10 = q1.営業日数10, 営業日数11 = q1.営業日数11, 営業日数12 = q1.営業日数12, 営業日数合計 = q1.営業日数1 + q1.営業日数2 + q1.営業日数3 + q1.営業日数4 + q1.営業日数5 + q1.営業日数6 + q1.営業日数7 + q1.営業日数8 + q1.営業日数9 + q1.営業日数10 + q1.営業日数11 + q1.営業日数12, 稼働日数1 = q1.稼働日数1, 稼働日数2 = q1.稼働日数2, 稼働日数3 = q1.稼働日数3, 稼働日数4 = q1.稼働日数4, 稼働日数5 = q1.稼働日数5, 稼働日数6 = q1.稼働日数6, 稼働日数7 = q1.稼働日数7, 稼働日数8 = q1.稼働日数8, 稼働日数9 = q1.稼働日数9, 稼働日数10 = q1.稼働日数10, 稼働日数11 = q1.稼働日数11, 稼働日数12 = q1.稼働日数12, 稼働日数合計 = q1.稼働日数1 + q1.稼働日数2 + q1.稼働日数3 + q1.稼働日数4 + q1.稼働日数5 + q1.稼働日数6 + q1.稼働日数7 + q1.稼働日数8 + q1.稼働日数9 + q1.稼働日数10 + q1.稼働日数11 + q1.稼働日数12, 前年対比1 = q2g.前年対比1, 前年対比2 = q2g.前年対比2, 前年対比3 = q2g.前年対比3, 前年対比4 = q2g.前年対比4, 前年対比5 = q2g.前年対比5, 前年対比6 = q2g.前年対比6, 前年対比7 = q2g.前年対比7, 前年対比8 = q2g.前年対比8, 前年対比9 = q2g.前年対比9, 前年対比10 = q2g.前年対比10, 前年対比11 = q2g.前年対比11, 前年対比12 = q2g.前年対比12, 前年対比合計 = q2g.前年対比1 + q2g.前年対比2 + q2g.前年対比3 + q2g.前年対比4 + q2g.前年対比5 + q2g.前年対比6 + q2g.前年対比7 + q2g.前年対比8 + q2g.前年対比9 + q2g.前年対比10 + q2g.前年対比11 + q2g.前年対比12, 前月対比1 = q3g.前月対比1, 前月対比2 = q3g.前月対比2, 前月対比3 = q3g.前月対比3, 前月対比4 = q3g.前月対比4, 前月対比5 = q3g.前月対比5, 前月対比6 = q3g.前月対比6, 前月対比7 = q3g.前月対比7, 前月対比8 = q3g.前月対比8, 前月対比9 = q3g.前月対比9, 前月対比10 = q3g.前月対比10, 前月対比11 = q3g.前月対比11, 前月対比12 = q3g.前月対比12, 前月対比合計 = q3g.前月対比1 + q3g.前月対比2 + q3g.前月対比3 + q3g.前月対比4 + q3g.前月対比5 + q3g.前月対比6 + q3g.前月対比7 + q3g.前月対比8 + q3g.前月対比9 + q3g.前月対比10 + q3g.前月対比11 + q3g.前月対比12, コードFrom = p車輌From, コードTo = p車輌To, ピックアップ指定 = s車輌List, //開始日付 = 開始年月1, //終了日付 = 終了年月12, }).AsQueryable(); //query.AsEnumerable().Where(q => q.月1 = ) #endregion //SRY24010_DATASET dset = new SRY24010_DATASET() //{ // 売上構成グラフ = query1, // 得意先上位グラフ = query2, // 傭車先上位グラフ = query3, // 損益分岐点グラフ = query4, //}; var query2 = (from q in query group q by q.車輌ID into qGroup select new SRY24010_Member2 { 車輌ID = qGroup.Key, 総売上 = qGroup.Select(q => (q.稼働日数1 + q.稼働日数2 + q.稼働日数3 + q.稼働日数4 + q.稼働日数5 + q.稼働日数6 + q.稼働日数7 + q.稼働日数8 + q.稼働日数9 + q.稼働日数10 + q.稼働日数11 + q.稼働日数12)).Sum(), }).AsQueryable(); query2 = query2.Where(q => q.総売上 != 0 && q.総売上 != null); query = (from q in query let qqlet = from qq in query2 select qq.車輌ID where qqlet.Contains(q.車輌ID) select q).AsQueryable(); #region 車輌指定 var query3 = query; //車輌From処理 Min値 if (!string.IsNullOrEmpty(p車輌From)) { int i車輌From = AppCommon.IntParse(p車輌From); query = query.Where(c => c.車輌ID >= i車輌From || c.車輌ID == 999999999); } //車輌To処理 Max値 if (!string.IsNullOrEmpty(p車輌To)) { int i車輌TO = AppCommon.IntParse(p車輌To); query = query.Where(c => c.車輌ID <= i車輌TO || c.車輌ID == 999999999); } if (p車輌List.Length > 0) { if ((string.IsNullOrEmpty(p車輌From)) && (string.IsNullOrEmpty(p車輌To))) { query = query3.Where(q => p車輌List.Contains(q.車輌ID) || q.車輌ID == 999999999); } else { query = query.Union(query3.Where(q => p車輌List.Contains(q.車輌ID) || q.車輌ID == 999999999)); } } query = query.Distinct(); #endregion query = query.OrderBy(q => q.車輌ID); var result = query.ToList(); foreach (SRY24010_Member1 row in result) { row.稼働率1 = row.営業日数1 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数1.ToString()) / (row.営業日数1) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率2 = row.営業日数2 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数2.ToString()) / (row.営業日数2) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率3 = row.営業日数3 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数3.ToString()) / (row.営業日数3) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率4 = row.営業日数4 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数4.ToString()) / (row.営業日数4) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率5 = row.営業日数5 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数5.ToString()) / (row.営業日数5) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率6 = row.営業日数6 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数6.ToString()) / (row.営業日数6) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率7 = row.営業日数7 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数7.ToString()) / (row.営業日数7) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率8 = row.営業日数8 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数8.ToString()) / (row.営業日数8) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率9 = row.営業日数9 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数9.ToString()) / (row.営業日数9) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率10 = row.営業日数10 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数10.ToString()) / (row.営業日数10) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率11 = row.営業日数11 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数11.ToString()) / (row.営業日数11) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率12 = row.営業日数12 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数12.ToString()) / (row.営業日数12) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.稼働率合計 = row.営業日数合計 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数合計.ToString()) / (row.営業日数合計) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比1 = row.前年対比1 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数1.ToString()) / (row.前年対比1) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比2 = row.前年対比2 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数2.ToString()) / (row.前年対比2) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比3 = row.前年対比3 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数3.ToString()) / (row.前年対比3) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比4 = row.前年対比4 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数4.ToString()) / (row.前年対比4) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比5 = row.前年対比5 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数5.ToString()) / (row.前年対比5) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比6 = row.前年対比6 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数6.ToString()) / (row.前年対比6) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比7 = row.前年対比7 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数7.ToString()) / (row.前年対比7) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比8 = row.前年対比8 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数8.ToString()) / (row.前年対比8) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比9 = row.前年対比9 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数9.ToString()) / (row.前年対比9) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比10 = row.前年対比10 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数10.ToString()) / (row.前年対比10) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比11 = row.前年対比11 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数11.ToString()) / (row.前年対比11) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比12 = row.前年対比12 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数12.ToString()) / (row.前年対比12) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前年対比合計 = row.前年対比合計 == 0 ? 0 : Math.Round(AppCommon.DecimalParse((AppCommon.DecimalParse(row.稼働日数合計.ToString()) / (row.前年対比合計) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比1 = row.前月対比1 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数1) / (row.前月対比1) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比2 = row.前月対比2 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数2) / (row.前月対比2) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比3 = row.前月対比3 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数3) / (row.前月対比3) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比4 = row.前月対比4 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数4) / (row.前月対比4) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比5 = row.前月対比5 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数5) / (row.前月対比5) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比6 = row.前月対比6 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数6) / (row.前月対比6) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比7 = row.前月対比7 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数7) / (row.前月対比7) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比8 = row.前月対比8 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数8) / (row.前月対比8) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比9 = row.前月対比9 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数9) / (row.前月対比9) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比10 = row.前月対比10 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数10) / (row.前月対比10) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比11 = row.前月対比11 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数11) / (row.前月対比11) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比12 = row.前月対比12 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数12) / (row.前月対比12) * 100).ToString()), 1, MidpointRounding.AwayFromZero); row.前月対比合計 = row.前月対比合計 == 0 ? 0 : Math.Round(AppCommon.DecimalParse(((row.稼働日数合計) / (row.前月対比合計) * 100).ToString()), 1, MidpointRounding.AwayFromZero); } ; return(result); } catch (Exception ex) { throw ex; } } }