public void RefreshGrid() { try { var list = itembal.GetByYear(UserSettings.LogInYear); DataTable itmTable = new DataTable(); using (var reader = ObjectReader.Create(list, "DocID", "ItemNo", "Description", "IsLocked" )) { itmTable.Load(reader); mgridList.DataSource = itmTable; } dgvorig.DataSource = mgridList.DataSource; Grid.ListCheck(mgridList, listTS); tslblRowCount.Text = "Number of Records: " + list.Count + " "; } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } }
private void ContinueCopy() { try { FormHelpers.CursorWait(true); List <tbl_000_H_ITEM> write_list_itm; selyear = Convert.ToInt32(mcboYear.SelectedValue.ToString()); if (!mcbOverWrite.Checked) { msg = "This process will copy previous components from the selected year to the current logged in year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Copy case YearsOf.Components: Save_com(false); break; #endregion #region Tabulation to Copy case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: Save_pi(false); break; case MaintainanceTableSub.VacuumPlating: Save_vp(false); break; case MaintainanceTableSub.Assembly: Save_assy(false); break; } break; #endregion #region Process to Copy case YearsOf.ProcessSetup: Save_proc(false); break; #endregion #region Items to Copy case YearsOf.Items: write_list_itm = new List <tbl_000_H_ITEM>(); var currentyear_list_itm = itmbal.GetByYear(UserSettings.LogInYear).ToList(); foreach (tbl_000_H_ITEM i in currentyear_list_itm) { write_list_itm.Add(itmbal.GetAll().Where(w => w.YEARUSED == selyear && w.ItemNo == i.ItemNo).FirstOrDefault()); } foreach (tbl_000_H_ITEM i in write_list_itm) { if (i != null) { itmlist.RemoveAll(r => r.ItemNo == i.ItemNo); } } Save_item(); break; #endregion } } } else { msg = "This process will remove the existing components and replace it with the selected year. Do you want to continue?"; if (MessageHelpers.ShowQuestion(msg) == DialogResult.Yes) { switch (YearSource) { #region Components to Copy with Overwrite case YearsOf.Components: Save_com(true); break; #endregion #region Tabulation to Copy with Overwrite case YearsOf.MaintainanceTable: switch (YearofMaintenanceTable_Sub) { case MaintainanceTableSub.PlasticInjection: Save_pi(true); break; case MaintainanceTableSub.VacuumPlating: Save_vp(true); break; case MaintainanceTableSub.Assembly: Save_assy(true); break; } break; #endregion #region Process to Copy with Overwrite case YearsOf.ProcessSetup: Save_proc(true); break; #endregion #region Items to Copy with Overwrite case YearsOf.Items: write_list_itm = new List <tbl_000_H_ITEM>(); foreach (tbl_000_H_ITEM i in itmlist) { write_list_itm.Add(itmbal.GetAll().Where(w => w.YEARUSED == UserSettings.LogInYear && w.ItemNo == i.ItemNo).FirstOrDefault()); } AssignSubItems(write_list_itm); if (BPSUtilitiesV1.NZ(write_list_itm, "").ToString() != "") { foreach (tbl_000_H_ITEM i in write_list_itm) { if (i != null) { todelete_item.Add(i); } } var tmptodelete_item = todelete_item; itmbal.Delete_List(todelete_item); //AssignSubItems(itmlist); DeleteSub(todelete_item); Save_item(); } break; #endregion } } } this.Close(); } catch (Exception ex) { MessageHelpers.ShowError(ex.Message); } finally { FormHelpers.CursorWait(false); } }