private void btnPreview_Click(object sender, EventArgs e) { try { if (TransactionGridView.GetFocusedRow() is Transactions item) { BillingStatementViewModel billingStatementViewModel = new BillingStatementViewModel() { TransactionId = item.Id }; var billing = new UnitOfWork().BillingsRepo.Find(x => x.TransactionId == item.Id); billing.AmountInWord = "**" + StringExtensions.NumberToWords(billing.Amount.ToString("##.##00")) + "**"; billing.BillingStatementViewModels = new List <BillingStatementViewModel>() { billingStatementViewModel }; frmReportViewer frmReportViewer = new frmReportViewer(new rptOfficialReceipt() { DataSource = new List <Billings>() { billing } }); frmReportViewer.ShowDialog(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public JsonResult returnZone(string a) { BillingStatementViewModel billingStatementViewModel = new BillingStatementViewModel(); int zonegroupid = db.ZoneGroup.FirstOrDefault(m => m.ZoneGroupCode == a).ZoneGroupId; billingStatementViewModel.zone = db.Zone.Where(m => m.ZoneGroup == zonegroupid.ToString()).ToList(); billingStatementViewModel.billingPeriod = db.BillingPeriod.OrderByDescending(x => x.BillingPeriodId).Where(m => m.groupCode == a).ToList(); return(Json(billingStatementViewModel)); }
public JsonResult returnZone(string a) { BillingStatementViewModel billingStatementViewModel = new BillingStatementViewModel(); int zonegroupid = db.ZoneGroup.FirstOrDefault(m => m.ZoneGroupCode == a).ZoneGroupId; var user = context.Roles.ToList(); var cashiers = user.Where(m => m.Name == "Cashier").ToList(); List <String> applicationUsers = new List <String>(); var userid = User.Identity.GetUserId(); string zoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; var ZoneList = db.Database.SqlQuery <DeveloperDetails>("SELECT DISTINCT Zones.ZoneName, Zones.ZoneCode FROM AspNetUserRoles INNER JOIN AspNetRoles ON AspNetRoles.Id = AspNetUserRoles.RoleId INNER JOIN AspNetUsers ON AspNetUserRoles.UserId = AspNetUsers.Id INNER JOIN Zones ON Zones.ZoneId = AspNetUsers.Zone WHERE AspNetRoles.RoleNumber = 7 AND AspNetUsers.ZoneGroup = '" + zoneGroup + "'").ToList(); //foreach (var item in cashiers) //{ // var ab = item.Users; // foreach (var item1 in item.Users) // { // try // { // var cd = item1.UserId; // var ef = context.Users.Where(m => m.Id == cd).FirstOrDefault(); // if (ef.ZoneGroup == a) // { // int zoneid = 0; // if (int.TryParse(ef.Zone, out zoneid)) // zoneid = int.Parse(ef.Zone); // var userZone = db.Zone.Any(m => m.ZoneId == zoneid) ? db.Zone.Where(m => m.ZoneId == zoneid).FirstOrDefault().ZoneName : "Zone name not found."; // applicationUsers.Add(userZone); // } // } // catch (Exception ex) // { // throw; // } // } //} ////var asd = applicationUsers.ToList(); //billingStatementViewModel.zoneName = applicationUsers.Distinct().ToList(); //billingStatementViewModel.billingPeriod = db.BillingPeriod.Where(m => m.groupCode == a).ToList(); return(Json(ZoneList)); }