Example #1
0
        public void GateHistoryPrepareIDList(GateHistory oGateHistory, bool bMultiSelect)
        {
            oGateHistory.ID     = null;
            oGateHistory.IDList = null;
            int?nGateHistoryID = 0;

            if (bMultiSelect && grdData.IsCheckerShow)
            {
                oGateHistory.IDList = "";

                DataView dMarked = new DataView(oGateHistoryList.MainTable);
                dMarked.RowFilter = "IsMarked = true";
                dMarked.Sort      = grdData.GridSource.Sort;
                foreach (DataRowView r in dMarked)
                {
                    if (!Convert.IsDBNull(r["ID"]))
                    {
                        nGateHistoryID      = (int)r["ID"];
                        oGateHistory.IDList = oGateHistory.IDList + nGateHistoryID.ToString() + ",";
                    }
                }
            }
            else
            {
                nGateHistoryID = (int?)grdData.CurrentRow.Cells["grcID"].Value;
                if (nGateHistoryID.HasValue)
                {
                    oGateHistory.ID = nGateHistoryID;
                }
            }
        }
Example #2
0
        private GateHistory oGateHistoryCur;         //текущий рейс

        public frmGatesHistory()
        {
            oGateHistoryList = new GateHistory();
            oGateHistoryCur  = new GateHistory();
            if (oGateHistoryList.ErrorNumber != 0 ||
                oGateHistoryCur.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                InitializeComponent();
            }
        }
Example #3
0
        public frmGatesHistoryEdit(int?_nGateHistoryID)
        {
            if (_nGateHistoryID.HasValue)
            {
                nGateHistoryID = (int)_nGateHistoryID;
            }

            oGateHistory = new GateHistory();
            if (oGateHistory.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                InitializeComponent();
            }
        }
Example #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (grdData.Rows.Count == 0 || grdData.CurrentRow == null ||
                !oGateHistoryCur.ID.HasValue)
            {
                return;
            }

            // перечитать
            int nGateHistoryID = (int)oGateHistoryCur.ID;

            oGateHistoryCur.ReFillOne(nGateHistoryID);

            // проверки:
            GateHistory oGateHistoryTemp = new GateHistory();

            // дл¤ нашей машины: нельз¤ удалить выезд, если уже есть въезд
            if (oGateHistoryCur.WayBillID.HasValue && oGateHistoryCur.IsDeparture)
            {
                oGateHistoryTemp.FilterWayBillsList = oGateHistoryCur.WayBillID.ToString();
                oGateHistoryTemp.FillData();
                if (oGateHistoryTemp.ErrorNumber == 0 && oGateHistoryTemp.MainTable != null &&
                    oGateHistoryTemp.MainTable.Rows.Count > 1)
                {
                    foreach (DataRow gh in oGateHistoryTemp.MainTable.Rows)
                    {
                        if ((int)gh["ID"] != nGateHistoryID)
                        {
                            if (!Convert.ToBoolean(gh["IsDeparture"]) && Convert.ToInt32(gh["ID"]) > nGateHistoryID)                             // вЏезд
                            {
                                RFMMessage.MessageBoxError("ƒл¤ данного факта выезда машины \"" + gh["CarNumber"].ToString() + "\" зарегистрирован факт въезда (по тому же путевому листу)...\n" +
                                                           "”даление невозможно.");
                                return;
                            }
                        }
                    }
                }
            }
            // дл¤ ненашей машины: нельз¤ удалить въезд, если уже есть выезд
            if (oGateHistoryCur.PassID.HasValue && !oGateHistoryCur.IsDeparture)
            {
                oGateHistoryTemp.FilterPassesList = oGateHistoryCur.PassID.ToString();
                oGateHistoryTemp.FillData();
                if (oGateHistoryTemp.ErrorNumber == 0 && oGateHistoryTemp.MainTable != null &&
                    oGateHistoryTemp.MainTable.Rows.Count > 1)
                {
                    foreach (DataRow gh in oGateHistoryTemp.MainTable.Rows)
                    {
                        if ((int)gh["ID"] != nGateHistoryID)
                        {
                            if (Convert.ToBoolean(gh["IsDeparture"]) && Convert.ToInt32(gh["ID"]) > nGateHistoryID)                             // вџезд
                            {
                                RFMMessage.MessageBoxError("ƒл¤ данного факта въезда машины \"" + gh["CarNumber"].ToString() + "\" зарегистрирован факт выезда (по тому же пропуску)...\n" +
                                                           "”даление невозможно.");
                                return;
                            }
                        }
                    }
                }
            }

            if (RFMMessage.MessageBoxYesNo("”далить запись о пересечении ворот машиной " + oGateHistoryCur.CarNumber + " " + oGateHistoryCur.DateCross.ToString("dd.MM.yyyy HH.mm") + "?") == DialogResult.Yes)
            {
                if (oGateHistoryCur.Delete(nGateHistoryID))
                {
                    grdData_Restore();
                }
            }
        }