Exemple #1
0
        private void frmPartnersEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            oPartner.ID = nPartnerID;

            // классификаторы
            bResult = cboZone_Restore() && cboPermitLevel_Restore(); /*&& cboPartnerRoot_Restore();*/
            if (bResult)
            {
                cboPartnerRoot.SelectedIndex         =
                    cboZone.SelectedIndex            =
                        cboPermitLevel.SelectedIndex =
                            -1;

                if (nPartnerID.HasValue && (int)nPartnerID != 0)
                {
                    // существующий клиент
                    bResult = oPartner.ReFillOne((int)nPartnerID) && (oPartner.ErrorNumber == 0);
                    if (bResult)
                    {
                        Text += " (код " + nPartnerID.ToString() + ")";

                        txtNаme.Text               = oPartner.Name;
                        chkActual.Checked          = oPartner.Actual;
                        chkIsCustomer.Checked      = oPartner.IsCustomer;
                        chkIsSupplier.Checked      = oPartner.IsSupplier;
                        chkIsTransport.Checked     = oPartner.IsTransport;
                        chkIsOwner.Checked         = oPartner.IsOwner;
                        chkSeparatePicking.Checked = oPartner.SeparatePicking;
                        chkIsOwner_CheckedChanged(null, null);

                        txtContactsInfo.Text = oPartner.ContactsInfo;

                        if (oPartner.PartnerRootID.HasValue)
                        {
                            cboPartnerRoot.SelectedValue = oPartner.PartnerRootID;
                        }
                        if (oPartner.ZoneID.HasValue)
                        {
                            cboZone.SelectedValue = oPartner.ZoneID;
                        }
                        if (oPartner.PermitLevelID.HasValue)
                        {
                            cboPermitLevel.SelectedValue = oPartner.PermitLevelID;
                        }

                        txtDeliveryAddress.Text     = oPartner.DeliveryAddress;
                        txtDeliveryPassage.Text     = oPartner.DeliveryPassage;
                        txtDeliveryRestriction.Text = oPartner.DeliveryRestriction;

                        txtGravity.Text = oPartner.Gravity;

                        txtNote.Text = oPartner.Note;

                        // CoordinatesX, CoordinatesY
                        txtLatitude.Text  = (oPartner.Latitude.HasValue ? oPartner.Latitude.ToString() : "");
                        txtLongitude.Text = (oPartner.Longitude.HasValue ? oPartner.Longitude.ToString() : "");

                        numDistance.Value = oPartner.Distance;

                        chkPassengerCarOnly.Checked = oPartner.PassengerCarOnly;
                        chkPosternOnly.Checked      = oPartner.PosternOnly;
                        chkLoadLiftOnly.Checked     = oPartner.LoadLiftOnly;

                        //  покажем верхнюю запись из PartnersDetail
                        oPartner.FillTablePartnersDetails((int)oPartner.ID);
                        if (oPartner.TablePartnersDetails.Rows.Count > 0)
                        {
                            DataRow p = oPartner.TablePartnersDetails.Rows[0];

                            txtLegalName.Text    = p["LegalName"].ToString();
                            txtLegalAddress.Text = p["LegalAddress"].ToString();
                            txtFactName.Text     = p["FactName"].ToString();
                            txtFactAddress.Text  = p["FactAddress"].ToString();
                            txtPhone.Text        = p["Phone"].ToString();
                            txtInn.Text          = p["Inn"].ToString();
                            txtKpp.Text          = p["Kpp"].ToString();

                            txtContractNumber.Text = p["ContractNumber"].ToString();
                            if (!Convert.IsDBNull(p["ContractDate"]))
                            {
                                dtpContractDate.Value = Convert.ToDateTime(p["ContractDate"]);
                            }
                            else
                            {
                                dtpContractDate.HideControl(false);
                            }

                            txtBankName.Text    = p["BankName"].ToString();
                            txtBankAddress.Text = p["BankAddress"].ToString();
                            txtPAccount.Text    = p["PAccount"].ToString();
                            txtCAccount.Text    = p["CAccount"].ToString();
                            txtBik.Text         = p["Bik"].ToString();
                            txtOkonh.Text       = p["Okonh"].ToString();
                            txtOkpo.Text        = p["Okpo"].ToString();

                            txtJobTitleDirector.Text   = p["JobTitleDirector"].ToString();
                            txtFioDirector.Text        = p["FioDirector"].ToString();
                            txtJobTitleAccountant.Text = p["JobTitleAccountant"].ToString();
                            txtFioAccountant.Text      = p["FioAccountant"].ToString();
                        }
                        //

                        // стр.Дополнительно
                        chkDateValidControl.Checked = oPartner.DateValidControl;
                        chkPalletsAgreement.Checked = oPartner.PalletsAgreement;
                        chkFactPaymentOnly.Checked  = oPartner.FactPaymentOnly;

                        txtTimeWork.Text     = oPartner.TimeWork;
                        txtTimeReceipt.Text  = oPartner.TimeReceipt;
                        txtTimePay.Text      = oPartner.TimePay;
                        txtTimeRest.Text     = oPartner.TimeRest;
                        numStayMinutes.Value = oPartner.StayMinutes;

                        // стр.Шаблоны
                        if (oPartner.PF_BillName != null && oPartner.PF_BillName.Length > 0)
                        {
                            txtPF_BillName.Text = oPartner.PF_BillName;
                        }
                        numPF_BillCopiesCount.Value = oPartner.PF_BillCopiesCount;
                        chkPF_Bill.Checked          = txtPF_BillName.Text.Trim().Length > 0 || numPF_BillCopiesCount.Value > 0;
                        if (oPartner.PF_FactureName != null && oPartner.PF_FactureName.Length > 0)
                        {
                            txtPF_FactureName.Text = oPartner.PF_FactureName;
                        }
                        numPF_FactureCopiesCount.Value = oPartner.PF_FactureCopiesCount;
                        chkPF_Facture.Checked          = txtPF_FactureName.Text.Trim().Length > 0 || numPF_FactureCopiesCount.Value > 0;
                        if (oPartner.PF_PayBillName != null && oPartner.PF_PayBillName.Length > 0)
                        {
                            txtPF_PayBillName.Text = oPartner.PF_PayBillName;
                        }
                        numPF_PayBillCopiesCount.Value = oPartner.PF_PayBillCopiesCount;
                        chkPF_PayBill.Checked          = txtPF_PayBillName.Text.Trim().Length > 0 || numPF_PayBillCopiesCount.Value > 0;

                        txtShopCode.Text = oPartner.ShopCode;

                        // стр.Ветеринария
                        txtVeterinaryPartnerName.Text = oPartner.VeterinaryPartnerName;
                        txtVeterinaryPermission.Text  = oPartner.VeterinaryPermission;

                        // not used

                        /*
                         * chkFactureNeed.Checked = oPartner.FactureNeed;
                         * chkWarrantNeed.Checked = oPartner.WarrantNeed;
                         * chkPaymentOrderNeed.Checked = oPartner.PaymentOrderNeed;
                         * chkOtherDocumentsNeed.Checked = oPartner.OtherDocumentsNeed;
                         * chkQualityLicenceNeed.Checked = oPartner.QualityLicenceNeed;
                         * chkVeterinaryLicenceNeed.Checked = oPartner.VeterinaryLicenceNeed;
                         */
                    }

                    if (oPartner.DrivingScheme != null && !Convert.IsDBNull(oPartner.DrivingScheme))
                    {
                        byte[]       bsPhoto = oPartner.DrivingScheme;
                        MemoryStream ms      = new MemoryStream(bsPhoto);
                        try
                        {
                            picDrivingScheme.Image = new Bitmap(ms);
                        }
                        catch (Exception ex)
                        {
                            RFMMessage.MessageBoxError("Ошибка загрузки схемы проезда: " + ex.Message);
                        }
                    }
                }
                else
                {
                    // новый клиент
                    chkActual.Checked = true;
                }

                // только просмотр
                if (bNoEdit)
                {
                    RFMPanelGlass pnlGlass = new RFMPanelGlass();
                    pnlGlass.Top    = pnlData.Top;
                    pnlGlass.Left   = pnlData.Left;
                    pnlGlass.Width  = pnlData.Width;
                    pnlGlass.Height = pnlData.Height;
                    Controls.Add(pnlGlass);
                    pnlGlass.BringToFront();

                    btnSave.Select();
                    btnSave.Enabled = false;
                    Text           += " - просмотр";
                }
                else
                {
                    // доступность полей
                    DBTable dbTable = new DBTable();
                    foreach (Control oControlTemp in Controls)
                    {
                        ControlEnable(dbTable, oControlTemp);
                    }
                }

                chkPF_Bill_CheckedChanged(null, null);
                chkPF_Facture_CheckedChanged(null, null);
                chkPF_PayBill_CheckedChanged(null, null);
            }

            if (!bResult)
            {
                Dispose();
            }

            bLoaded = true;
        }
Exemple #2
0
        private void frmCarsEdit_Load(object sender, EventArgs e)
        {
            bool bResult = true;

            lblZoneName.Text = "";

            oCar.ID = nCarID;

            // классификаторы
            bResult = cboCarType_Restore() &&
                      cboCarClass_Restore() &&
                      cboPermitLevel_Restore() &&
                      cboDriver_Restore() &&
                      cboFuelType_Restore();

            if (bResult)
            {
                if (nCarID.HasValue && (int)nCarID != 0)
                {
                    // существующая машина
                    bResult = oCar.ReFillOne((int)nCarID) && (oCar.ErrorNumber == 0);
                    if (bResult)
                    {
                        Text += " (" + nCarID.ToString() + ")";

                        txtCarNаme.Text       = oCar.Name;
                        txtCarNumber.Text     = oCar.CarNumber;
                        txtTrailerNumber.Text = oCar.TrailerNumber;
                        txtCarModel.Text      = oCar.CarModel;

                        cboCarType.SelectedValue  = oCar.CarTypeID;
                        cboCarClass.SelectedValue = oCar.CarClassID;

                        chkActual.Checked            = oCar.Actual;
                        chkForGoodsOnly.Checked      = oCar.ForGoodsOnly;
                        chkOperable.Checked          = oCar.Operable;
                        chkIsPassengerCar.Checked    = oCar.IsPassengerCar;
                        chkIsPostern.Checked         = oCar.IsPostern;
                        chkIsLoadLift.Checked        = oCar.IsLoadLift;
                        cboPermitLevel.SelectedValue = oCar.PermitLevelID;

                        numTonnage.Value       = oCar.Tonnage;
                        numWeight.Value        = oCar.Weight;
                        numVolume.Value        = oCar.Volume;
                        numMaxPalletsQnt.Value = oCar.MaxPalletsQnt;
                        numMaxPointsQnt.Value  = oCar.MaxPointsQnt;

                        int nHours   = Convert.ToInt32(Math.Floor((decimal)oCar.MaxDurationMinutes / 60));
                        int nMinutes = oCar.MaxDurationMinutes - nHours * 60;
                        txtMaxDuration.Text = dEmptyDate.AddHours(nHours).AddMinutes(nMinutes).ToString("HH:mm");
                        txtNote.Text        = oCar.Note;
                        if (oCar.DriverEmployeeID.HasValue)
                        {
                            cboDriver.SelectedValue = oCar.DriverEmployeeID;
                        }
                        else
                        {
                            cboDriver.SelectedIndex = -1;
                        }
                        if (oCar.ZoneName != null && oCar.ZoneName.Length > 0)
                        {
                            lblZoneName.Text = "(" + oCar.ZoneName + ")";
                        }

                        if (oCar.FuelTypeID.HasValue)
                        {
                            cboFuelType.SelectedValue = oCar.FuelTypeID;
                        }
                        else
                        {
                            cboFuelType.SelectedIndex = -1;
                        }
                        chkAutoFreezer.Checked      = oCar.AutoFreezer;
                        numFuelTank.Value           = oCar.FuelTank;
                        numFuelQuotaSummer.Value    = oCar.FuelQuotaSummer;
                        numFuelQuotaWinter.Value    = oCar.FuelQuotaWinter;
                        numFreezerTank.Value        = oCar.FreezerTank;
                        numFreezerQuotaSummer.Value = oCar.FreezerQuotaSummer;
                        numFreezerQuotaWinter.Value = oCar.FreezerQuotaWinter;
                    }
                }
                else
                {
                    // новая машина
                    chkActual.Checked                         = true;
                    cboCarType.SelectedIndex                  =
                        cboCarClass.SelectedIndex             =
                            cboPermitLevel.SelectedIndex      =
                                cboDriver.SelectedIndex       =
                                    cboFuelType.SelectedIndex =
                                        -1;
                }

                // только просмотр
                if (bNoEdit)
                {
                    RFMPanelGlass pnlGlass = new RFMPanelGlass();
                    pnlGlass.Top    = pnlData.Top;
                    pnlGlass.Left   = pnlData.Left;
                    pnlGlass.Width  = pnlData.Width;
                    pnlGlass.Height = pnlData.Height;
                    Controls.Add(pnlGlass);
                    pnlGlass.BringToFront();

                    IsStopTab = true;

                    btnSave.Select();
                    btnSave.Enabled = false;
                    Text           += " - просмотр";
                }
            }

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