Ejemplo n.º 1
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(this.serialNo.Text) || String.IsNullOrEmpty(this.damageDesc.Text))
     {
         MessageBox.Show("Wypełnij wszystkie pola formularza");
     }
     else
     if (new DeviceRepairCard().add(((ComboBoxItem)this.serialNo.SelectedItem).HiddenValue, this.damageDesc.Text))
     {
         home.notifyIcon1.Icon            = SystemIcons.Application;
         home.notifyIcon1.BalloonTipText  = "Dodano kartę naprawy";
         home.notifyIcon1.BalloonTipTitle = "Dodawanie kart napraw";
         home.notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
         home.notifyIcon1.Visible         = true;
         home.notifyIcon1.ShowBalloonTip(3000);
         User     user     = new User();
         object[] userData = user.getData(user.getCurrentUserId());
         var      device   = new DeviceCard().getDeviceData(((ComboBoxItem)this.serialNo.SelectedItem).HiddenValue);
         new Printer(userData[1].ToString(), device.manufacturer, device.model, device.serial_no, new DeviceType().getName(device.type_id), damageDesc.Text, userData[0].ToString());
         this.Close();
     }
     else
     {
         home.notifyIcon1.Icon            = SystemIcons.Exclamation;
         home.notifyIcon1.BalloonTipText  = "Wystąpił błąd podczas dodawania karty naprawy. Sprawdź poprawność wprowadzanych danych i spróbuj ponownie";
         home.notifyIcon1.BalloonTipTitle = "Dodawanie kart napraw";
         home.notifyIcon1.BalloonTipIcon  = ToolTipIcon.Error;
         home.notifyIcon1.Visible         = true;
         home.notifyIcon1.ShowBalloonTip(3000);
     }
 }
Ejemplo n.º 2
0
        public void display()
        {
            if (new User().isSuperadmin())
            {
                this.placeBox.Visible   = true;
                this.placeLabel.Visible = true;
                if (placeBox.Items.Count == 0)
                {
                    foreach (var p in new ProjektEntities().Places)
                    {
                        this.placeBox.Items.Add(new ComboBoxItem(p.address, p.id));
                    }
                }
            }
            DeviceCard dc    = new DeviceCard();
            Place      place = new Place();

            tableLayoutPanel1.RowStyles[0].Height = 18;
            bool rep, diagnosis, note;

            rep       = this.repaired.Text == "TAK" ? true : false;
            diagnosis = this.diagnosisBox.Text == "TAK" ? true : false;
            note      = this.noteBox.Text == "TAK" ? true : false;
            if (this.add_date == false)
            {
                this.addFrom.Value = DateTime.Now;
                this.addTo.Value   = DateTime.Now;
            }
            if (this.edit_date == false)
            {
                this.changeFrom.Value = DateTime.Now;
                this.changeTo.Value   = DateTime.Now;
            }

            int placeId;

            try
            {
                placeId = ((ComboBoxItem)this.placeBox.SelectedItem).HiddenValue;
            }
            catch (NullReferenceException)
            {
                placeId = 0;
            }

            deviceRepairCardList.DataSource = new DeviceRepairCard().list(rep, diagnosis, note, this.addFrom.Value, this.addTo.Value, this.add_date,
                                                                          this.changeFrom.Value, this.changeTo.Value, this.edit_date, placeId
                                                                          );
            deviceRepairCardList.Columns[0].HeaderText  = "ID";
            deviceRepairCardList.Columns[1].HeaderText  = "Opis uszkodzenia";
            deviceRepairCardList.Columns[2].HeaderText  = "Diagnoza";
            deviceRepairCardList.Columns[3].HeaderText  = "Notatka z naprawy";
            deviceRepairCardList.Columns[4].HeaderText  = "Naprawione";
            deviceRepairCardList.Columns[5].HeaderText  = "Utworzone";
            deviceRepairCardList.Columns[6].HeaderText  = "Edytowane";
            deviceRepairCardList.Columns[7].Visible     = false;
            deviceRepairCardList.Columns[8].Visible     = false;
            deviceRepairCardList.Columns[9].HeaderText  = "Numer seryjny";
            deviceRepairCardList.Columns[10].Visible    = false;
            deviceRepairCardList.Columns[11].HeaderText = "Miejsce";

            for (int i = 0; i < deviceRepairCardList.RowCount; i++)
            {
                deviceRepairCardList.Rows[i].Cells[9].Value  = (dc.getDeviceData(Convert.ToInt32(deviceRepairCardList.Rows[i].Cells[7].Value.ToString())).serial_no).ToString();
                deviceRepairCardList.Rows[i].Cells[11].Value = place.getAddress(Convert.ToInt32(deviceRepairCardList.Rows[i].Cells[8].Value)).ToString();
            }
        }