private void btnFilter_Click(object sender, EventArgs e) { WaitOn(this); oGoods.ClearError(); oGoods.ClearFilters(); // собираем услови¤ if (ucSelectRecordID_GoodsGroups.IsSelectedExist) { oGoods.FilterGoodsGroupsList = ucSelectRecordID_GoodsGroups.GetIdString(); } if (ucSelectRecordID_GoodsBrands.IsSelectedExist) { oGoods.FilterGoodsBrandsList = ucSelectRecordID_GoodsBrands.GetIdString(); } if (txtGoodBarCode.Text.Trim().Length > 0) { oGoods.FilterGoodBarCode = txtGoodBarCode.Text.Trim(); } if (txtName.Text.Trim().Length > 0) { oGoods.FilterGoodNameContext = txtName.Text.Trim(); } if (chkGoodsActual.Checked) { oGoods.FilterGoodsActual = true; } if (chkPackingsActual.Checked) { oGoods.FilterPackingsActual = true; } if (nHostID.HasValue || nUserHostID.HasValue) { if (nHostID.HasValue) { oGoods.FilterHostsList = nHostID.ToString(); } if (nUserHostID.HasValue) { oGoods.FilterHostsList = nUserHostID.ToString(); } } else { if (ucSelectRecordID_Hosts.IsSelectedExist) { oGoods.FilterHostsList = ucSelectRecordID_Hosts.GetIdString(); } } if (tvwGoods.Visible && tvwGoods.TreeSource != null && tvwGoods.GetMarkedNodes() > 0) { tvwGoods.TreeSource.Filter = "IsMarked"; tvwGoods.TreeSource.MoveFirst(); for (int i = 0; i < tvwGoods.TreeSource.Count; i++) { oGoods.GoodsIDList = oGoods.GoodsIDList + "," + ((DataRowView)tvwGoods.TreeSource.Current)["ID"]; tvwGoods.TreeSource.MoveNext(); } tvwGoods.TreeSource.RemoveFilter(); } grdData.DataSource = null; oGoods.FillData(); if ((chkWeightNot.Checked) || (chkWeight.Checked)) { DataTable dt = CopyTable(oGoods.MainTable, "dt", ((chkWeightNot.Checked) ? "not " : "") + "Weighting", "GoodAlias, GoodID, PackingID"); oGoods.MainTable.Clear(); oGoods.MainTable.Merge(dt); } grdData.Restore(oGoods.MainTable); WaitOff(this); /* // восстановить отмеченные записи * if (ucSelect != null) * { * if (ucSelect.IsSaveMark) * ucSelect.RestoreMarks(grdData); * } */ grdData.Select(); }
private void grdData_Restore() { oGoods.ClearError(); oGoods.ClearFilters(); // собираем условия if (ucSelectRecordID_GoodsGroups.IsSelectedExist) { oGoods.FilterGoodsGroupsList = ucSelectRecordID_GoodsGroups.GetIdString(); } if (ucSelectRecordID_GoodsBrands.IsSelectedExist) { oGoods.FilterGoodsBrandsList = ucSelectRecordID_GoodsBrands.GetIdString(); } if (txtGoodBarCode.Text.Trim().Length > 0) { oGoods.FilterGoodBarCode = txtGoodBarCode.Text.Trim(); } if (txtName.Text.Trim().Length > 0) { oGoods.FilterGoodNameContext = txtName.Text.Trim(); } if (chkGoodsActual.Checked) { oGoods.FilterGoodsActual = true; } if (chkPackingsActual.Checked) { oGoods.FilterPackingsActual = true; } if (nHostID.HasValue || nUserHostID.HasValue) { if (nHostID.HasValue) { oGoods.FilterHostsList = nHostID.ToString(); } if (nUserHostID.HasValue) { oGoods.FilterHostsList = nUserHostID.ToString(); } } else { if (ucSelectRecordID_Hosts.IsSelectedExist) { oGoods.FilterHostsList = ucSelectRecordID_Hosts.GetIdString(); } } if (tvwGoods.Visible && tvwGoods.TreeSource != null && tvwGoods.GetMarkedNodes() > 0) { tvwGoods.TreeSource.Filter = "IsMarked"; tvwGoods.TreeSource.MoveFirst(); for (int i = 0; i < tvwGoods.TreeSource.Count; i++) { oGoods.FilterGoodsIDList = oGoods.FilterGoodsIDList + "," + ((DataRowView)tvwGoods.TreeSource.Current)["ID"]; tvwGoods.TreeSource.MoveNext(); } tvwGoods.TreeSource.RemoveFilter(); } oGoods.FillData(); // артикул if (txtArticul.Text.Trim().Length > 0) { tTable = CopyTable(oGoods.MainTable, "tTable", "Articul LIKE '*" + txtArticul.Text.Trim().ToUpper() + "*'", ""); } else { tTable = oGoods.MainTable; } grdData.Restore(tTable); }