private void insert_btn_Click(object sender, EventArgs e)
        {
            // For taking the Image

            byte[]       imageBt = null;
            FileStream   fstream = new FileStream("", FileMode.Open, FileAccess.Read);
            BinaryReader br      = new BinaryReader(fstream);

            imageBt = br.ReadBytes((int)fstream.Length);

            Plant plt = new Plant();

            {
                plt.Plant_id                = Convert.ToInt16(ID_txtbx.Text);
                plt.Vpp_id                  = Convert.ToInt16(virtual_power_plant_id_txtbx.Text);
                plt.Vpp_region              = vpp_region_txt_bx.Text;
                plt.Plant_generating_type   = generating_planttype_txtbx.Text;
                plt.Date_of_aquisition      = date_of_aquisition_txtbx.Text;
                plt.Power_in_KW             = Convert.ToInt16(power_txtbx.Text);
                plt.Manufacturer            = manufacturer_txtbx.Text;
                plt.Purchase_price_in_Euros = purchase_price_txtbx.Text;
                plt.Location                = location_txtbx.Text;
                plt.Operating_time          = Convert.ToInt16(operating_time_txtbx.Text);
                plt.Plane_image             = imageBt;
            }
            PlantBusiness.AddPlant(plt);
            MessageBox.Show("Data Inserted Successfully", "Data Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
        private void OnSavePlant()
        {
            switch (_operationStatus)
            {
            case OperationStatus.ADD:
                if (_detailedViewPlant != null)
                {
                    // add plant to persistence
                    _pBusiness.AddPlant(_detailedViewPlant);

                    // add plant to list - update view
                    _plants.Add(DetailedViewPlant);
                }
                break;

            case OperationStatus.EDIT:
                PlantDetail plantToUpdate = _plants.FirstOrDefault(c => c.Id == SelectedPlant.Id);

                if (plantToUpdate != null)
                {
                    // update plant in persistence
                    _pBusiness.UpdatePlant(DetailedViewPlant);

                    // update plant in list - update view
                    _plants.Remove(plantToUpdate);
                    _plants.Add(DetailedViewPlant);
                }
                break;

            default:
                break;
            }

            ResetDetailedViewPlant();
            IsEditingAdding  = false;
            ShowAddButton    = true;
            _operationStatus = OperationStatus.NONE;
        }