private void btnPrepareAct_Click(object sender, EventArgs e) { if (grdData.CurrentRow == null) { return; } int nID = (int)grdData.CurrentRow.Cells["grcID"].Value; // проверить, закрыта ли уже копия CellContentSnapshot oCellContentSnapshotTemp = new CellContentSnapshot(); oCellContentSnapshotTemp.ID = nID; oCellContentSnapshotTemp.FillData(); if (oCellContentSnapshotTemp.ErrorNumber != 0 || oCellContentSnapshotTemp.MainTable == null || oCellContentSnapshotTemp.MainTable.Rows.Count != 1) { RFMMessage.MessageBoxError("Ошибка при проверке копии..."); return; } if (Convert.IsDBNull(oCellContentSnapshotTemp.MainTable.Rows[0]["DateEnd"])) { RFMMessage.MessageBoxError("Копия еще не закрыта..."); return; } StartForm(new frmCCSPrepareInventoryAct(nID)); }
private bool grdDetailGroupByCells_Restore() { grdDetailGroupByCells.GetGridState(); grdDetailGroupByCells.DataSource = null; if (grdData.Rows.Count == 0 || oCellContentSnapshotCur.ID == null || grdData.CurrentRow != null && grdData.IsStatusRow(grdData.CurrentRow.Index)) { return(true); } RFMCursorWait.Set(true); RFMCursorWait.LockWindowUpdate(FindForm().Handle); // не показываем для незакрытых копий oCellContentSnapshotCur.FillData(); if (oCellContentSnapshotCur.ErrorNumber != 0 || oCellContentSnapshotCur.MainTable == null || oCellContentSnapshotCur.MainTable.Rows.Count != 1 || Convert.IsDBNull(oCellContentSnapshotCur.MainTable.Rows[0]["DateEnd"])) { RFMCursorWait.LockWindowUpdate(IntPtr.Zero); RFMCursorWait.Set(false); return(true); } oCellContentSnapshotList.ClearError(); oCellContentSnapshotList.FillTableCellsContentsSnapshotsDetails((int)oCellContentSnapshotCur.ID, 2, false, chkExcludeLostFoundEndGroupByCells.Checked, chkDiffOnly.Checked, chkInInventoryOnly.Checked); DataTable tableCellContentSnapshotsDetailsGroupByCells = oCellContentSnapshotList.TableCellsContentsSnapshotsDetails; grdDetailGroupByCells.Restore(tableCellContentSnapshotsDetailsGroupByCells); RFMCursorWait.LockWindowUpdate(IntPtr.Zero); RFMCursorWait.Set(false); return(oCellContentSnapshotList.ErrorNumber == 0); }
private void btnCreate_Click(object sender, EventArgs e) { // проверить, нет ли уже незакрытой копии CellContentSnapshot oCellContentSnapshotTemp = new CellContentSnapshot(); oCellContentSnapshotTemp.FilterIsClosed = false; oCellContentSnapshotTemp.FillData(); if (oCellContentSnapshotTemp.ErrorNumber != 0 || oCellContentSnapshotTemp.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при проверке существующих копий..."); return; } if (oCellContentSnapshotTemp.MainTable.Rows.Count > 0) { RFMMessage.MessageBoxError("Существуют незакрытые копии...\n\rОткрытие новой копии невозможно."); return; } if (RFMMessage.MessageBoxYesNo("Открыть новую копию?") != DialogResult.Yes) { return; } oCellContentSnapshotTemp.ClearFilters(); string sNote = ""; if (StartForm(new frmInputBoxString("Примечание для копии:", sNote)) == DialogResult.Yes) { Refresh(); sNote = GotParam[0].ToString(); if (oCellContentSnapshotTemp.Create(0, ((RFMFormMain)Application.OpenForms[0]).UserID, sNote)) { grdData_Restore(); if (oCellContentSnapshotTemp.ID.HasValue && oCellContentSnapshotTemp.ID > 0) { grdData.GridSource.Position = grdData.GridSource.Find(oCellContentSnapshotList.ColumnID, Convert.ToInt32(oCellContentSnapshotTemp.ID)); } } } }
private bool grdData_Restore() { RFMCursorWait.Set(true); RFMCursorWait.LockWindowUpdate(FindForm().Handle); oCellContentSnapshotCur.ID = null; oCellContentSnapshotList.ClearError(); oCellContentSnapshotList.ClearFilters(); oCellContentSnapshotList.ID = null; oCellContentSnapshotList.IDList = null; // собираем условия // даты if (!dtrDates.dtpBegDate.IsEmpty) { oCellContentSnapshotList.FilterDateBeg = dtrDates.dtpBegDate.Value.Date; } if (!dtrDates.dtpEndDate.IsEmpty) { oCellContentSnapshotList.FilterDateEnd = dtrDates.dtpEndDate.Value.Date; } // владельцы if (sSelectedOwnersIDList.Length > 0) { oCellContentSnapshotList.FilterOwnersList = sSelectedOwnersIDList; } // состояния if (sSelectedGoodsStatesIDList.Length > 0) { oCellContentSnapshotList.FilterGoodsStatesList = sSelectedGoodsStatesIDList; } // ячейки if (sSelectedCellsIDList.Length > 0) { oCellContentSnapshotList.FilterCellsList = sSelectedCellsIDList; } // товары if (sSelectedPackingIDList.Length > 0) { oCellContentSnapshotList.FilterPackingsList = sSelectedPackingIDList; } // подтверждение if (optIsClosed.Checked) { oCellContentSnapshotList.FilterIsClosed = true; } if (optIsClosedNot.Checked) { oCellContentSnapshotList.FilterIsClosed = false; } // grdDetailBeg.DataSource = null; grdDetailEnd.DataSource = null; grdDetailGroupByCells.DataSource = null; grdDetailGroupAll.DataSource = null; grdData.GetGridState(); oCellContentSnapshotList.FillData(); grdData.IsLockRowChanged = true; grdData.Restore(oCellContentSnapshotList.MainTable); tmrRestore.Enabled = true; RFMCursorWait.LockWindowUpdate(IntPtr.Zero); RFMCursorWait.Set(false); return(oCellContentSnapshotList.ErrorNumber == 0); }
private void btnClose_Click(object sender, EventArgs e) { if (grdData.CurrentRow == null) { return; } int nID = (int)grdData.CurrentRow.Cells["grcID"].Value; // проверить, не закрыта ли уже копия CellContentSnapshot oCellContentSnapshotTemp = new CellContentSnapshot(); oCellContentSnapshotTemp.ID = nID; oCellContentSnapshotTemp.FillData(); if (oCellContentSnapshotTemp.ErrorNumber != 0 || oCellContentSnapshotTemp.MainTable == null || oCellContentSnapshotTemp.MainTable.Rows.Count != 1) { RFMMessage.MessageBoxError("Ошибка при проверке копии..."); return; } if (!Convert.IsDBNull(oCellContentSnapshotTemp.MainTable.Rows[0]["DateEnd"])) { RFMMessage.MessageBoxError("Копия уже закрыта..."); return; } // проверить состояние ревизий Inventory oInventory = new Inventory(); // нет ли незакрытых ревизий среди привязанных? oInventory.FilterCellContentSnapshotID = nID; oInventory.FilterConfirmed = false; oInventory.FillData(); if (oInventory.ErrorNumber != 0 || oInventory.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при проверке незавершенных ревизий..."); return; } if (oInventory.MainTable.Rows.Count > 0) { if (RFMMessage.MessageBoxYesNo("Обнаружены незавершенные ревизии, связанные с текущей копией остатков......\n" + "Все-таки закрыть текущую копию остатков?") != DialogResult.Yes) { return; } } // нет ли неоткрытых ревизий, подготовленных в ближайшем прошлом oInventory.ClearFilters(); oInventory.FilterStarted = false; oInventory.FilterDateBeg = DateTime.Now.Date.AddDays(-7); oInventory.FillData(); if (oInventory.ErrorNumber != 0 || oInventory.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при необработанных ревизий..."); return; } if (oInventory.MainTable.Rows.Count > 0) { if (RFMMessage.MessageBoxYesNo("Обнаружены необработанные ревизии, оформленные в ближайший прошедший период...\n" + "Все-таки закрыть текущую копию остатков?") != DialogResult.Yes) { return; } } // // все проверили, можно закрывать if (RFMMessage.MessageBoxYesNo("Закрыть текущую копию?") != DialogResult.Yes) { return; } if (oCellContentSnapshotTemp.Close(nID, ((RFMFormMain)Application.OpenForms[0]).UserID)) { grdData_Restore(); } }