private void CmsDbCon_Load(object sender, EventArgs e) { Worker.WorkerReportsProgress = true; Worker.WorkerSupportsCancellation = true; radProgressBar1.Value1 = 0; lblProgressState.Text = ""; btnSaveSync.Enabled = false; this.isLocalConnected = false; this.isMainConnected = false; testMainConnection.Visible = false; testLocalConnection.Visible = false; bcoService = new BranchCorpOfficeBL(GlobalVars.UnitOfWork); revenutUnitTypeService = new RevenueUnitTypeBL(GlobalVars.UnitOfWork); revenueUnitService = new RevenueUnitBL(GlobalVars.UnitOfWork); _branchCorpOffices = bcoService.FilterActive().OrderBy(x => x.BranchCorpOfficeName).ToList(); revenueUnitTypes = revenutUnitTypeService.FilterActive().OrderBy(x => x.RevenueUnitTypeName).ToList(); revenueUnits = revenueUnitService.FilterActive().OrderBy(x => x.RevenueUnitName).ToList(); // Load BranchCorpOffices lstBco.DataSource = _branchCorpOffices; lstBco.DisplayMember = "BranchCorpOfficeName"; lstBco.ValueMember = "BranchCorpOfficeId"; // Load RevenueUnitTypes lstRevenueUnitType.DataSource = revenueUnitTypes; lstRevenueUnitType.DisplayMember = "RevenueUnitTypeName"; lstRevenueUnitType.ValueMember = "RevenueUnitTypeId"; // Load RevenueUnits lstRevenueUnit.DataSource = revenueUnits; lstRevenueUnit.DisplayMember = "RevenueUnitName"; lstRevenueUnit.ValueMember = "RevenueUnitId"; _branchCorpOfficeId = GlobalVars.DeviceBcoId.ToString(); _filter = ConfigurationManager.AppSettings["Filter"].ToString(); _localConnectionString = ConfigurationManager.ConnectionStrings["Cms"].ConnectionString; _mainConnectionString = ConfigurationManager.ConnectionStrings["CmsCentral"].ConnectionString; _isSubserver = ConfigurationManager.AppSettings["isSubserver"].ToString(); SetChekcBoxes(); SetEntities(); gridTables.DataSource = _entities; radProgressBar1.Maximum = _entities.Count() + 5; if (_isSubserver.ToLower() == "false") { txtServerIP.Enabled = false; txtServerDbName.Enabled = false; txtServerUsername.Enabled = false; txtServerPassword.Enabled = false; isMainConnected = true; radPageViewPage2.Enabled = false; } }
//Complete Filter public DataTable getBranchAcceptanceDataByFilter(DateTime date, Guid?revenueUnitId, string driver, Guid?batchId) { RevenueUnitBL revenueunitservice = new RevenueUnitBL(); BatchBL batchservice = new BatchBL(); BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL(); ShipmentBL shipmentService = new ShipmentBL(); BranchCorpOfficeBL bcoService = new BranchCorpOfficeBL(); //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); // List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver).ToList(); //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); List <BranchAcceptanceViewModel> list = new List <BranchAcceptanceViewModel>(); List <BranchAcceptance> branchAcceptance = branchAcceptanceBl.FilterActive(). Where( x => x.RecordStatus == 1 //&& ((x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Users.Employee.AssignedToArea.RevenueUnitId != Guid.Empty) || (x.Users.Employee.AssignedToArea.RevenueUnitId == x.Users.Employee.AssignedToArea.RevenueUnitId && revenueUnitId == Guid.Empty)) && ((x.BatchID == batchId && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchId == Guid.Empty)) && ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); string revenueunitname = ""; string batchname = ""; string bcoName = ""; if (batchId != Guid.Empty) { batchname = batchservice.FilterActive().Find(x => x.BatchID == batchId).BatchName; } else { batchname = "All"; } if (revenueUnitId != Guid.Empty) { revenueunitname = revenueunitservice.FilterActive().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; } else { revenueunitname = "All"; } bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; list = Match(branchAcceptance, shipments). FindAll (x => ((x.Area == revenueunitname && x.Area != "N/A") || (x.Area == x.Area && revenueunitname == "All")) && ((x.Driver == driver && x.Driver != "N/A") || (x.Driver == x.Driver && driver == "All")) && ((x.Batch == batchname && x.Batch != "N/A") || (x.Batch == x.Batch && batchname == "All")) && ((x.BCO == bcoName && x.BCO != "N/A") || (x.BCO == x.BCO && bcoName == "")) && !x.Area.Contains("Walk-in")); //if (revenueUnitId != Guid.Empty && batchId !=Guid.Empty) //{ // batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName; // revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname && x.Batch == batchname); //} //else if (revenueUnitId == Guid.Empty && batchId != Guid.Empty) //{ // batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Batch == batchname && x.Area != "N/A"); //} //else if (revenueUnitId != Guid.Empty && batchId == Guid.Empty) //{ // revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname); //} //else //{ // bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; // list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName && x.Area != "N/A"); // //list = Match(branchAcceptance, shipments); //} DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("Area/Branch", typeof(string))); dt.Columns.Add(new DataColumn("Driver", typeof(string))); dt.Columns.Add(new DataColumn("Checker", typeof(string))); dt.Columns.Add(new DataColumn("Plate #", typeof(string))); dt.Columns.Add(new DataColumn("Batch", typeof(string))); dt.Columns.Add(new DataColumn("AWB", typeof(string))); dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Total Qty", typeof(string))); dt.Columns.Add(new DataColumn("BCO", typeof(string))); dt.Columns.Add(new DataColumn("BSO", typeof(string))); dt.Columns.Add(new DataColumn("ScannedBy", typeof(string))); dt.Columns.Add(new DataColumn("Remarks", typeof(string))); dt.Columns.Add(new DataColumn("Notes", typeof(string))); dt.BeginLoadData(); int ctr = 1; foreach (BranchAcceptanceViewModel item in list) { DataRow row = dt.NewRow(); row[0] = ctr++.ToString(); row[1] = item.Area.ToString(); row[2] = item.Driver.ToString(); row[3] = item.Checker.ToString(); row[4] = item.PlateNo.ToString(); row[5] = item.Batch.ToString(); row[6] = item.AirwayBillNo.ToString(); row[7] = item.TotalRecieved.ToString(); row[8] = item.TotalDiscrepency.ToString(); row[9] = item.Total.ToString(); row[10] = item.BCO; row[11] = item.BSO; row[12] = item.ScannedBy; row[13] = item.Remarks; row[14] = item.Notes; dt.Rows.Add(row); } dt.EndLoadData(); return(dt); }