public decimal GetCMperGL(string hospital, string fund_code, string section_code, string analytical_code, string value_date, string don_inc_exp) { decimal result = new decimal(); var donBalance = DonationBalanceRepository.GetDonationBalance(hospital, fund_code, section_code, analytical_code, value_date); if (donBalance.Count() > 0) { if (don_inc_exp == "E") { result = donBalance.First().Expenditure; } else if (don_inc_exp == "I") { result = donBalance.First().Income; } } return(result); }
public List <DonationUploadRecord> RecordValidation(List <DonationUploadRecord> record_list, string user_group, string user_inst_code, DateTime current_date, string value_date, int financial_year, out int valid_rec_cnt, out int invalid_rec_cnt) { valid_rec_cnt = 0; invalid_rec_cnt = 0; foreach (var r in record_list) { if (r.Record_error == 0) { var ds = DonSupercatRepository.GetSuperCatByDesc(r.Don_super_cat_desc); if (ds == null) { r.Record_error = 19; } else { r.Don_super_cat = ds.SupercatId; } if (r.Don_super_cat == 0) { r.Don_super_cat = 7; } } if (r.Record_error == 0) { var ds = DonCatRepository.GetDonCatByDesc(r.Don_cat_desc); if (ds == null) { r.Record_error = 1; } else { r.Don_cat = ds.Id; } if (r.Don_cat == 0) { r.Don_cat = 7; } } if (r.Record_error == 0) { if (r.Don_subcat_desc != "") { var ds = DonSubcatRepository.GetDonSubcatByCatIdDesc(r.Don_subcat_desc, r.Don_cat); if (ds == null) { if (r.Don_specific != "") { var ds2 = DonSubcatRepository.GetDonSubcatByCatIdSpec(r.Don_cat); if (ds2 != null) { r.Don_subcat = ds2.Id; } } else { r.Record_error = 2; } } else { r.Don_subcat = ds.Id; } } else { r.Don_subcat = 0; } if (r.Don_subcat == 0) { var ds = DonSubcatRepository.GetDonSubcatByCatId(r.Don_cat).Count(); if (ds > 0) { r.Record_error = 3; } } } if (r.Record_error == 0) { if (r.Don_subsubcat_desc != "") { var ds = DonSubsubcatRepository.GetDonSubsubcatBySubCatIdDesc(r.Don_subsubcat_desc, r.Don_subcat); if (ds == null) { r.Record_error = 4; } else { r.Don_subsubcat = ds.Id; } } else { r.Don_subsubcat = 0; } } if (r.Record_error == 0) { if (Int32.TryParse(r.Don_type_c, out int number)) { r.Don_type = number; } else { r.Don_type = 2; r.Record_error = 5; } if (r.Record_error == 0) { var ds = DonTypeRepository.GetDonTypeById(r.Don_type).Count(); if (ds <= 0) { r.Record_error = 5; } } } if (r.Record_error == 0) { if (Int32.TryParse(r.Don_purpose_c, out int number)) { r.Don_purpose = number; } else { r.Don_purpose = 2; r.Record_error = 6; } if (r.Record_error == 0) { var ds = DonPurposeRepository.GetDonPurposeById(r.Don_purpose).Count(); if (ds <= 0) { r.Record_error = 6; } } } if (r.Record_error == 0) { if (r.Recurrent_con == "N") { r.Recurrent_cost = 0; } else if (String.IsNullOrEmpty(r.Recurrent_cost_c)) { r.Recurrent_cost = 0; } else if (Int32.TryParse(r.Recurrent_cost_c, out int number)) { r.Recurrent_cost = number; } else { r.Record_error = 7; r.Recurrent_cost = 0; } } if (r.Record_error == 0) { if (user_group != "HOSP") { var ds = UserGroupHospRespository.GetUserGpHospByGpHosp(user_group, r.Hospital).Count(); if (ds <= 0) { r.Record_error = 8; } } else { if (r.Hospital != user_inst_code) { r.Record_error = 8; } } } if (r.Trust == 1 && r.Donor_type == "T") { r.Record_error = 17; } if (r.Record_error == 0) { if (string.IsNullOrEmpty(r.Don_cur_mth_c)) { r.Don_cur_mth_c = "0"; r.Don_cur_mth = 0; } else if (Decimal.TryParse(r.Don_cur_mth_c, out decimal number)) { r.Don_cur_mth = number; } else { r.Don_cur_mth = 0; r.Record_error = 10; } } if (r.Record_error == 0) { if (string.IsNullOrEmpty(r.Out_comm_c)) { r.Out_comm_c = "0"; r.Out_comm = 0; } else if (Int32.TryParse(r.Out_comm_c, out int number)) { r.Out_comm = number; } else { r.Out_comm = 0; r.Record_error = 11; } } if (r.Record_error == 0) { if (r.Don_date_c.Trim().Length != 8 && r.Don_date_c.Trim().Length != 10) { r.Record_error = 12; } //if (r.Record_error == 0) //{ // if (!Int32.TryParse(r.Don_date_c, out int number)) // r.Record_error = 12; //} //if (r.Record_error == 0) //{ // bool don_date_result = Int32.TryParse(r.Don_date_c, out int number); // if (!(number >= 1000000 && number <= 9999999)) // r.Record_error = 12; //} } if (r.Record_error == 0) { if (r.Don_date > current_date) { r.Record_error = 13; } if (r.Don_date < DateTime.ParseExact(financial_year + "0401", "yyyyMMdd", CultureInfo.InvariantCulture)) { r.Record_error = 14; } if (r.Don_date.ToString("yyyyMM") != value_date.Substring(0, 6)) { r.Record_error = 15; } } if (r.Record_error == 0) { if (r.Don_kind_desc.Trim() == "") { r.Record_error = 16; } } if (r.Record_error == 0) { if (r.Fund != "21" && r.Fund != "22" && r.Fund != "52") { r.Record_error = 18; } } if (r.Record_error == 0) { if (r.Section.Length != 7) { r.Record_error = 20; } } if (r.Record_error == 0) { if (r.Analytical.Length != 5) { r.Record_error = 21; } } if (r.Record_error == 0) { if (r.Maj_don1 != "Y" && r.Maj_don1 != "N") { r.Record_error = 22; } } if (r.Record_error == 0) { if (r.Maj_don2 != "Y" && r.Maj_don2 != "N") { r.Record_error = 23; } } if (r.Record_error == 0) { if (r.Maj_don3 != "Y" && r.Maj_don3 != "N") { r.Record_error = 24; } } if (r.Record_error == 0) { var ds = DonationBalanceRepository.GetDonationBalance(r.Hospital, r.Fund, r.Section, r.Analytical, value_date).Count(); if (ds <= 0) { r.Record_error = 25; } } if (r.Record_error == 0) { if (r.Don_inc_exp != "I" && r.Don_inc_exp != "E" && r.Don_inc_exp != "") { r.Record_error = 26; } } if (r.Record_error == 0) { var donation_bal = DonationBalanceRepository.GetDonationBalance(r.Hospital, r.Fund, r.Section, r.Analytical, value_date).First(); if (r.Don_inc_exp == "I") { var income_bal = donation_bal.Income; var income_input = DonationDetailRepository.GetIncomeInput(r.Hospital, r.Fund, r.Section, r.Analytical, value_date); if (income_bal - income_input < r.Don_cur_mth) { r.Record_error = 27; } } else { var exp_bal = donation_bal.Expenditure; var exp_input = DonationDetailRepository.GetExpenditure(r.Hospital, r.Fund, r.Section, r.Analytical, value_date); if (exp_bal - exp_input > r.Don_cur_mth) { r.Record_error = 27; } } } if (r.Record_error == 0) { var outstanding_SP = DonationDetailRepository.GetOutstanding(r.Hospital, r.Fund, r.Section, r.Analytical, value_date, r.Don_inc_exp); if (r.Don_inc_exp == "I") { if (outstanding_SP - r.Don_cur_mth < 0) { r.Record_error = 28; } } else { if (outstanding_SP - r.Don_cur_mth > 0) { r.Record_error = 29; } } } if (r.Record_error == 0) { valid_rec_cnt = valid_rec_cnt + 1; } else { invalid_rec_cnt = invalid_rec_cnt + 1; } if (r.Record_error != 0) { r.Err_msg = GetErrorMsg(r.Record_error); } } return(record_list); }