private void butMerge_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length < 2) { MessageBox.Show(Lan.g(this, "Please select at least two items first.")); return; } InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length]; for (int i = 0; i < listSelected.Length; i++) { listSelected[i] = InsPlans.GetPlan(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null); listSelected[i].NumberSubscribers = PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["subscribers"].ToString()); } FormInsPlansMerge FormI = new FormInsPlansMerge(); FormI.ListAll = listSelected; FormI.ShowDialog(); if (FormI.DialogResult != DialogResult.OK) { return; } //Do the merge. InsPlan planToMergeTo = FormI.PlanToMergeTo.Copy(); //List<Benefit> benList=Benefits.RefreshForPlan(planToMergeTo,0); Cursor = Cursors.WaitCursor; for (int i = 0; i < listSelected.Length; i++) //loop through each selected plan //skip the planToMergeTo, because it's already correct { if (planToMergeTo.PlanNum == listSelected[i].PlanNum) { continue; } //==Michael - We are changing plans here, but not carriers, so this is not needed: //SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName InsPlans.ChangeReferences(listSelected[i].PlanNum, planToMergeTo.PlanNum); Benefits.DeleteForPlan(listSelected[i].PlanNum); InsPlans.Delete(listSelected[i].PlanNum); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} } FillGrid(); //highlight the merged plan for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < listSelected.Length; j++) { if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString()) { gridMain.SetSelected(i, true); } } } Cursor = Cursors.Default; }
private void butMerge_Click(object sender,EventArgs e) { if(gridMain.SelectedIndices.Length<2) { MessageBox.Show(Lan.g(this,"Please select at least two items first.")); return; } InsPlan[] listSelected=new InsPlan[gridMain.SelectedIndices.Length]; for(int i=0;i<listSelected.Length;i++){ listSelected[i]=InsPlans.GetPlan(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()),null); listSelected[i].NumberSubscribers=PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["subscribers"].ToString()); } FormInsPlansMerge FormI=new FormInsPlansMerge(); FormI.ListAll=listSelected; FormI.ShowDialog(); if(FormI.DialogResult!=DialogResult.OK){ return; } //Do the merge. InsPlan planToMergeTo=FormI.PlanToMergeTo.Copy(); //List<Benefit> benList=Benefits.RefreshForPlan(planToMergeTo,0); Cursor=Cursors.WaitCursor; for(int i=0;i<listSelected.Length;i++){//loop through each selected plan //skip the planToMergeTo, because it's already correct if(planToMergeTo.PlanNum==listSelected[i].PlanNum){ continue; } //==Michael - We are changing plans here, but not carriers, so this is not needed: //SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName InsPlans.ChangeReferences(listSelected[i].PlanNum,planToMergeTo.PlanNum); Benefits.DeleteForPlan(listSelected[i].PlanNum); InsPlans.Delete(listSelected[i].PlanNum); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} } FillGrid(); //highlight the merged plan for(int i=0;i<table.Rows.Count;i++){ for(int j=0;j<listSelected.Length;j++){ if(table.Rows[i]["PlanNum"].ToString()==listSelected[j].PlanNum.ToString()){ gridMain.SetSelected(i,true); } } } Cursor=Cursors.Default; }
private void butMerge_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.InsPlanMerge)) { return; } if (gridMain.SelectedIndices.Length < 2) { MessageBox.Show(Lan.g(this, "Please select at least two items first.")); return; } InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length]; for (int i = 0; i < listSelected.Length; i++) { listSelected[i] = InsPlans.GetPlan(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null); listSelected[i].NumberSubscribers = PIn.Int(table.Rows[gridMain.SelectedIndices[i]]["subscribers"].ToString()); } FormInsPlansMerge FormI = new FormInsPlansMerge(); FormI.ListAll = listSelected; FormI.ShowDialog(); if (FormI.DialogResult != DialogResult.OK) { return; } //Do the merge. InsPlan planToMergeTo = FormI.PlanToMergeTo.Copy(); //List<Benefit> benList=Benefits.RefreshForPlan(planToMergeTo,0); Cursor = Cursors.WaitCursor; bool didMerge = false; List <long> listMergedPlanNums = new List <long>(); for (int i = 0; i < listSelected.Length; i++) //loop through each selected plan //skip the planToMergeTo, because it's already correct { if (planToMergeTo.PlanNum == listSelected[i].PlanNum) { continue; } //==Michael - We are changing plans here, but not carriers, so this is not needed: //SecurityLogs.MakeLogEntry(Permissions.InsPlanChangeCarrierName InsPlans.ChangeReferences(listSelected[i].PlanNum, planToMergeTo.PlanNum); Benefits.DeleteForPlan(listSelected[i].PlanNum); try { InsPlans.Delete(listSelected[i], canDeleteInsSub: false); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); SecurityLogs.MakeLogEntry(Permissions.InsPlanEdit, 0, Lan.g(this, "InsPlan Combine delete validation failed. Plan was not deleted."), listSelected[i].PlanNum, listSelected[i].SecDateTEdit); //new plan, no date needed. //Since we already deleted/changed all of the other dependencies, //we should continue in making the Securitylog entry and cleaning up. } didMerge = true; listMergedPlanNums.Add(listSelected[i].PlanNum); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} } if (didMerge) { string logText = Lan.g(this, "Merged the following PlanNum(s): ") + string.Join(", ", listMergedPlanNums) + " " + Lan.g(this, "into") + " " + planToMergeTo.PlanNum; SecurityLogs.MakeLogEntry(Permissions.InsPlanMerge, 0, logText); } FillGrid(); //highlight the merged plan for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < listSelected.Length; j++) { if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString()) { gridMain.SetSelected(i, true); } } } Cursor = Cursors.Default; }
private void butMerge_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length < 2) { MessageBox.Show(Lan.g(this, "Please select at least two items first.")); return; } InsPlan[] listSelected = new InsPlan[gridMain.SelectedIndices.Length]; for (int i = 0; i < listSelected.Length; i++) { listSelected[i] = InsPlans.GetPlan(PIn.PInt(table.Rows[gridMain.SelectedIndices[i]]["PlanNum"].ToString()), null); } FormInsPlansMerge FormI = new FormInsPlansMerge(); FormI.ListAll = listSelected; FormI.ShowDialog(); if (FormI.DialogResult != DialogResult.OK) { return; } //Do the merge. InsPlan planToMergeTo = FormI.PlanToMergeTo.Copy(); List <Benefit> benList = Benefits.RefreshForAll(planToMergeTo); Cursor = Cursors.WaitCursor; List <int> planNums; for (int i = 0; i < listSelected.Length; i++) //loop through each selected plan group //skip the planToMergeTo, because it's already correct { if (planToMergeTo.PlanNum == listSelected[i].PlanNum) { continue; } planNums = new List <int>(InsPlans.GetPlanNumsOfSamePlans(Employers.GetName(listSelected[i].EmployerNum), listSelected[i].GroupName, listSelected[i].GroupNum, listSelected[i].DivisionNo, Carriers.GetName(listSelected[i].CarrierNum), listSelected[i].IsMedical, listSelected[i].PlanNum, false));//remember that planNum=0 //First plan info InsPlans.UpdateForLike(listSelected[i], planToMergeTo); //for(int j=0;j<planNums.Count;j++) { //InsPlans.ComputeEstimatesForPlan(planNums[j]); //Eliminated in 5.0 for speed. //} //then benefits Benefits.UpdateListForIdentical(new List <Benefit>(), benList, planNums); //there will always be changes //Then PlanNote. This is much simpler than the usual synch, because user has seen all versions of note. InsPlans.UpdateNoteForPlans(planNums, planToMergeTo.PlanNote); } FillGrid(); //highlight the merged plan for (int i = 0; i < table.Rows.Count; i++) { for (int j = 0; j < listSelected.Length; j++) { if (table.Rows[i]["PlanNum"].ToString() == listSelected[j].PlanNum.ToString()) { gridMain.SetSelected(i, true); } } } Cursor = Cursors.Default; }