Beispiel #1
0
        private void btnReasonSelect_Click(object sender, EventArgs e)
        {
            // ранее введеные значения
            Pass oPassTemp = new Pass();

            oPassTemp.FilterDateEnd = DateTime.Now.Date.AddMonths(-1);
            oPassTemp.FilterDateEnd = DateTime.Now.Date;
            oPassTemp.FillData();
            if (oPassTemp.ErrorNumber != 0 || oPassTemp.MainTable == null)
            {
                return;
            }
            if (oPassTemp.MainTable.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("Нет данных...");
                return;
            }

            DataTable dtReasonDistinct = new DataTable();

            dtReasonDistinct.Columns.Add("Reason");
            System.Collections.Hashtable hash = new System.Collections.Hashtable();
            foreach (DataRow row in oPassTemp.MainTable.Rows)
            {
                hash[row["Reason"]] = row["Reason"];
            }
            foreach (object name in hash.Values)
            {
                dtReasonDistinct.Rows.Add(name);
            }
            DataTable tdReason = CopyTable(dtReasonDistinct, "tdReason", "Reason > ''", "Reason");

            if (StartForm(new frmSelectID(this, tdReason, "Reason", "Назначение", false)) == DialogResult.Yes)
            {
                if (_SelectedID == null)
                {
                    return;
                }
                txtReason.Text = _SelectedText;
            }
            _SelectedID   = null;
            _SelectedText = "";

            return;
        }
Beispiel #2
0
        private void btnCarSelect_Click(object sender, EventArgs e)
        {
            _SelectedID   = null;
            _SelectedText = "";

            // ранее введеные значения
            Pass oPassTemp = new Pass();

            oPass.FilterDateBeg = dtpDatePass.Value.Date.AddMonths(-12);
            oPassTemp.FillData();
            if (oPassTemp.ErrorNumber != 0 || oPassTemp.MainTable == null)
            {
                return;
            }
            if (oPassTemp.MainTable.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("Нет данных...");
                return;
            }

            DataTable tdCars = CopyTable(oPassTemp.MainTable, "tdCars", "", "CarName");

            if (StartForm(new frmSelectID(this, tdCars, "DatePass, CarName, CarNumber, DriverName, Reason", "Дата, Машина, Гос.номер, Водитель, Назначение", false)) == DialogResult.Yes)
            {
                if (_SelectedID == null)
                {
                    return;
                }
                oPassTemp.ClearData();
                oPassTemp.ReFillOne((int)_SelectedID);
                txtCarNаme.Text        = oPassTemp.CarName;
                txtCarTypeName.Text    = oPassTemp.CarTypeName;
                txtCarNumber.Text      = oPassTemp.CarNumber;
                txtTrailerNumber.Text  = oPassTemp.TrailerNumber;
                txtDriverName.Text     = oPassTemp.DriverName;
                txtDriverDocument.Text = oPassTemp.DriverDocument;
                txtDriverPhone.Text    = oPassTemp.DriverPhone;
                txtReason.Text         = oPassTemp.Reason;
            }
            _SelectedID   = null;
            _SelectedText = "";
        }
Beispiel #3
0
        private bool grdData_Restore()
        {
            RFMCursorWait.Set(true);
            RFMCursorWait.LockWindowUpdate(FindForm().Handle);

            oPassCur.ClearOne();

            oPassList.ClearError();
            oPassList.ClearFilters();
            oPassList.ID     = null;
            oPassList.IDList = null;

            // собираем условия

            // даты
            if (!dtrDates.dtpBegDate.IsEmpty)
            {
                oPassList.FilterDateBeg = dtrDates.dtpBegDate.Value.Date;
            }
            if (!dtrDates.dtpEndDate.IsEmpty)
            {
                oPassList.FilterDateEnd = dtrDates.dtpEndDate.Value.Date;
            }

            // машины, типы, водители
            // контексты
            if (txtCarTypeNameContext.Text.Trim().Length > 0)
            {
                oPassList.FilterCarTypeNameContext = txtCarTypeNameContext.Text.Trim().ToUpper();
            }
            if (txtCarNameContext.Text.Trim().Length > 0)
            {
                oPassList.FilterCarNameContext = txtCarNameContext.Text.Trim().ToUpper();
            }
            if (txtCarNumberContext.Text.Trim().Length > 0)
            {
                oPassList.FilterCarNumberContext = txtCarNumberContext.Text.Trim().ToUpper();
            }
            if (txtDriverNameContext.Text.Trim().Length > 0)
            {
                oPassList.FilterDriverNameContext = txtDriverNameContext.Text.Trim().ToUpper();
            }
            if (txtReasonContext.Text.Trim().Length > 0)
            {
                oPassList.FilterReasonContext = txtReasonContext.Text.Trim().ToUpper();
            }

            // состояние машины
            if (optPassesStatusNotInNotOut.Checked)
            {
                oPassList.FilterDateBegFull = false;
                oPassList.FilterDateEndFull = false;
            }
            if (optPassesStatusInNotOut.Checked)
            {
                oPassList.FilterDateBegFull = true;
                oPassList.FilterDateEndFull = false;
            }
            if (optPassesStatusInOut.Checked)
            {
                oPassList.FilterDateBegFull = true;
                oPassList.FilterDateEndFull = true;
            }

            // подтверждение
            if (optIsConfirmed.Checked)
            {
                oPassList.FilterIsConfirmed = true;
            }
            if (optIsConfirmedNot.Checked)
            {
                oPassList.FilterIsConfirmed = false;
            }

            // разрешение
            if (optIsPermitted.Checked)
            {
                oPassList.FilterIsPermitted = true;
            }
            if (optIsPermittedNot.Checked)
            {
                oPassList.FilterIsPermitted = false;
            }

            //

            grdTrips.DataSource = null;

            grdData.GetGridState();

            oPassList.FillData();
            grdData.IsLockRowChanged = true;
            grdData.Restore(oPassList.MainTable);
            tmrRestore.Enabled = true;

            RFMCursorWait.LockWindowUpdate(IntPtr.Zero);
            RFMCursorWait.Set(false);

            return(oPassList.ErrorNumber == 0);
        }
Beispiel #4
0
        private void frmPassesEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            // классификаторы
            if (!cboPartner_Restore() ||
                !cboCarrierPartner_Restore())
            {
                bResult = false;
            }

            if (bResult)
            {
                oPass.ID = nPassID;
                oPass.FillData();
                if (oPass.ErrorNumber != 0 || oPass.MainTable == null)
                {
                    bResult = false;
                }

                if (bResult)
                {
                    if (nPassID.HasValue && oPass.MainTable.Rows.Count != 1)
                    {
                        RFMMessage.MessageBoxError("Ошибка при получении данных о пропуске...");
                        bResult = false;
                    }
                }
            }

            if (bResult)
            {
                cboPartner.SelectedIndex            =
                    cboCarrierPartner.SelectedIndex =
                        -1;
                txtPartnerName.Text            =
                    txtCarrierPartnerName.Text =
                        "";

                if (nPassID.HasValue)
                {
                    // существующий пропуск
                    oPass.FillOne();

                    dtpDatePass.Value = oPass.DatePass;
                    txtReason.Text    = oPass.Reason;

                    txtCarNаme.Text        = oPass.CarName;
                    txtCarTypeName.Text    = oPass.CarTypeName;
                    txtCarNumber.Text      = oPass.CarNumber;
                    txtTrailerNumber.Text  = oPass.TrailerNumber;
                    txtDriverName.Text     = oPass.DriverName;
                    txtDriverDocument.Text = oPass.DriverDocument;
                    txtDriverPhone.Text    = oPass.DriverPhone;

                    numBrutto.Value     = oPass.Brutto;
                    numPalletsQnt.Value = oPass.PalletsQnt;

                    if (oPass.PartnerID.HasValue)
                    {
                        cboPartner.SelectedValue = (int)oPass.PartnerID;
                    }
                    txtPartnerName.Text = oPass.PartnerName;
                    if (oPass.CarrierPartnerID.HasValue)
                    {
                        cboCarrierPartner.SelectedValue = (int)oPass.CarrierPartnerID;
                    }
                    txtCarrierPartnerName.Text = oPass.CarrierPartnerName;

                    if (oPass.DateBegPlan.HasValue)
                    {
                        chkArrivalPlan.Checked = true;
                        chkArrivalPlan_CheckedChanged(null, null);
                        dtpArrivalPlan.Value = (DateTime)oPass.DateBegPlan;
                    }
                    else
                    {
                        dtpArrivalPlan.HideControl(false);
                    }
                    if (oPass.DateEndPlan.HasValue)
                    {
                        chkDeparturePlan.Checked = true;
                        chkDeparturePlan_CheckedChanged(null, null);
                        dtpDeparturePlan.Value = (DateTime)oPass.DateEndPlan;
                    }
                    else
                    {
                        dtpDeparturePlan.HideControl(false);
                    }
                    if (oPass.DateBeg.HasValue)
                    {
                        chkArrivalFact.Checked = true;
                        chkArrivalFact_CheckedChanged(null, null);
                        dtpArrivalFact.Value = (DateTime)oPass.DateBeg;
                    }
                    else
                    {
                        dtpArrivalFact.HideControl(false);
                    }
                    if (oPass.DateEnd.HasValue)
                    {
                        chkDepartureFact.Checked = true;
                        chkDepartureFact_CheckedChanged(null, null);
                        dtpDepartureFact.Value = (DateTime)oPass.DateEnd;
                    }
                    else
                    {
                        dtpDepartureFact.HideControl(false);
                    }

                    txtNote.Text = oPass.Note;
                }
                else
                {
                    dtpDatePass.Value = DateTime.Now;

                    dtpArrivalPlan.HideControl(false);
                    dtpDeparturePlan.HideControl(false);
                    dtpArrivalFact.HideControl(false);
                    dtpDepartureFact.HideControl(false);
                }
            }

            if (!bResult)
            {
                Dispose();
            }
        }