Exemplo n.º 1
0
        private void tmrRestore_Tick(object sender, EventArgs e)
        {
            tmrRestore.Enabled = false;

            if (grdData.CurrentRow == null)
            {
                return;
            }

            int rowIndex = grdData.CurrentRow.Index;

            btnPrint.Enabled       =
                btnService.Enabled =
                    true;

            if (grdData.IsStatusRow(rowIndex))
            {
                oPassCur.ClearOne();
                btnEdit.Enabled       =
                    btnDelete.Enabled =
                        false;
            }
            else
            {
                // заполнение объекта по текущей строке
                DataRow r = ((DataRowView)((DataGridViewRow)grdData.Rows[rowIndex]).DataBoundItem).Row;
                oPassCur.FillOne(r);
                btnEdit.Enabled   = (!oPassCur.DateConfirm.HasValue && !oPassCur.DateBeg.HasValue);
                btnDelete.Enabled = (!oPassCur.DateConfirm.HasValue && !oPassCur.DateBeg.HasValue);

                mniPassSetDateEntry.Enabled   = !oPassCur.DateBeg.HasValue;
                mniPassClearDateEntry.Enabled = oPassCur.DateBeg.HasValue;
                mniPassSetDateExit.Enabled    = !oPassCur.DateEnd.HasValue;
                mniPassClearDateExit.Enabled  = oPassCur.DateEnd.HasValue;

                mniPassConfirm.Enabled   = !oPassCur.IsClosed && !oPassCur.IsConfirmed;
                mniPassUnConfirm.Enabled = !oPassCur.IsClosed && oPassCur.IsConfirmed;
                mniPassPermit.Enabled    = !oPassCur.IsClosed && !oPassCur.IsPermitted;
                mniPassUnPermit.Enabled  = !oPassCur.IsClosed && oPassCur.IsPermitted;
                mniPassPrint.Enabled     = !oPassCur.IsClosed && oPassCur.IsPermitted;
            }
            tcPasses.SetAllNeedRestore(true);
        }
Exemplo n.º 2
0
        private void grdData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (grdData.DataSource == null)
            {
                return;
            }

            // статусная строка
            if (grdData.IsStatusRow(e.RowIndex))
            {
                if (grdData.Columns[e.ColumnIndex].Name.ToUpper().Contains("IMAGE"))
                {
                    e.Value = Properties.Resources.Empty;
                }
                return;
            }

            // строка данных
            DataRow            r = ((DataRowView)((DataGridViewRow)grdData.Rows[e.RowIndex]).DataBoundItem).Row;
            DataGridViewColumn c = grdData.Columns[e.ColumnIndex];

            oPassTemp.FillOne(r);
            //
            switch (c.Name)
            {
            case "grcPassStatusImage":
                if (oPassTemp.DateEnd.HasValue)
                {
                    e.Value = Properties.Resources.DotRed;
                }
                else
                {
                    if (oPassTemp.DateBeg.HasValue)
                    {
                        e.Value = Properties.Resources.DotYellow;
                    }
                    else
                    {
                        if (oPassTemp.IsConfirmed)
                        {
                            e.Value = Properties.Resources.DotGreen;
                        }
                        else
                        {
                            e.Value = Properties.Resources.Empty;
                        }
                    }
                }
                break;

            case "grcConfirmedImage":
                if (oPassTemp.DateConfirm.HasValue)
                {
                    e.Value = Properties.Resources.Check;
                }
                else
                {
                    e.Value = Properties.Resources.Empty;
                }
                break;

            case "grcIsPermittedImage":
                if (oPassTemp.IsPermitted)
                {
                    e.Value = Properties.Resources.CheckGreen;
                }
                else
                {
                    e.Value = Properties.Resources.Empty;
                }
                break;
            }
        }
Exemplo n.º 3
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();
            }
        }