Example #1
0
        private void accordionControlElement3_Click(object sender, EventArgs e)
        {
            try
            {
                bunifuCustomDataGrid2.Columns.Clear();
                bunifuCustomDataGrid2.ReadOnly = true;

                _computers = new Computers();
                if (_computers.GetShort().Rows.Count > 0)
                {
                    bunifuCustomDataGrid2.DataSource = _computers.GetShort();
                    //AddButton(bunifuCustomDataGrid2);
                    var name  = bunifuCustomDataGrid2.Rows[0].Cells[0].Value.ToString();
                    var price = int.Parse(bunifuCustomDataGrid2.Rows[0].Cells[1].Value.ToString());
                    var brand = bunifuCustomDataGrid2.Rows[0].Cells[3].Value.ToString();
                    var gpu   = bunifuCustomDataGrid2.Rows[0].Cells[4].Value.ToString();
                    var os    = bunifuCustomDataGrid2.Rows[0].Cells[7].Value.ToString();
                    var ram   = bunifuCustomDataGrid2.Rows[0].Cells[6].Value.ToString();
                    var date  = bunifuCustomDataGrid2.Rows[0].Cells[2].Value.ToString();
                    var cpu   = bunifuCustomDataGrid2.Rows[0].Cells[5].Value.ToString();

                    label51.Text = gpu;
                    label50.Text = os;
                    label49.Text = ram;
                    label36.Text = price.ToString();
                    label37.Text = brand;
                    label47.Text = name;
                    label48.Text = date;
                    label35.Text = cpu;

                    byte[] img;
                    if (_computers.GetByName(label47.Text, "Computers").Rows[0][12].ToString() != "NULL")
                    {
                        img = (byte[])(_computers.GetByName(label47.Text, "Computers").Rows[0][12]);
                        if (img == null)
                        {
                            pictureBox17.Image = null;
                        }
                        else
                        {
                            var ms = new MemoryStream(img);
                            pictureBox17.Image = Image.FromStream(ms);
                        }
                    }
                }

                xtraTabPage7.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void GetComputerInfo(string s)
        {
            try
            {
                var name  = tName.Text.Trim();
                var price = int.Parse(tPrice.Text.Trim());
                var piece = int.Parse(tPiece.Text.Trim());
                var date  = tDate.Text.Trim();
                var brand = tBrand.Text.Trim();
                var gpu   = tGPU.Text.Trim();
                var cpu   = tCPU.Text.Trim();
                var ram   = int.Parse(tRAM.Text.Trim());
                var ss    = float.Parse(tSS.Text.Trim());
                var os    = tOS.Text.Trim();
                var fs    = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
                var br    = new BinaryReader(fs);
                img = br.ReadBytes((int)fs.Length);

                switch (s)
                {
                case "add":
                {
                    var result = _comp.GetByName(name, "Computers");

                    if (result.Rows.Count > 0)
                    {
                        lberror.ForeColor = Color.Red;
                        lberror.Text      = CommonFunctions.ReturnString("exist");
                    }

                    else
                    {
                        _comp.Add(name, gpu, price, piece, date, brand, cpu, ram, ss, os);
                        _product.AddImage(int.Parse(_product.GetByName(name, "Computers").Rows[0][0].ToString()), img, "Computers");
                        lberror.ForeColor = Color.Green;
                        lberror.Text      = CommonFunctions.ReturnString("success");
                    }

                    break;
                }

                case "update":
                {
                    var id = int.Parse(tID.Text.Trim());

                    _comp.Update(id, name, gpu, price, piece, date, brand, cpu, ram, ss, os);
                    _comp.AddImage(id, img, "Computers");
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
        private void bunifuCustomDataGrid2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                var name  = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[0].Value.ToString();
                var price = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[1].Value.ToString();
                var brand = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[3].Value.ToString();
                var gpu   = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[4].Value.ToString();
                var os    = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[7].Value.ToString();
                var ram   = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[6].Value.ToString();
                var date  = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[2].Value.ToString();
                var cpu   = bunifuCustomDataGrid2.Rows[e.RowIndex].Cells[5].Value.ToString();

                label51.Text = gpu;
                label50.Text = os;
                label49.Text = ram;
                label36.Text = price;
                label37.Text = brand;
                label47.Text = name;
                label48.Text = date;
                label35.Text = cpu;

                byte[] img;
                if (_computers.GetByName(label47.Text, "Computers").Rows[0][12].ToString() == "NULL")
                {
                    return;
                }
                img = (byte[])(_computers.GetByName(label47.Text, "Computers").Rows[0][12]);
                if (img == null)
                {
                    pictureBox17.Image = null;
                }
                else
                {
                    var ms = new MemoryStream(img);
                    pictureBox17.Image = Image.FromStream(ms);
                }
            }
        }
Example #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (cb.SelectedIndex == 0)
     {
         if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "")
         {
             searchError.Text = "Parameters can not be empty.";
         }
         else
         {
             if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "")
             {
                 dataGridView1.DataSource = comp.GetById(int.Parse(searchID.Text.Trim()), "Computers");
             }
             else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "")
             {
                 dataGridView1.DataSource = comp.GetByName(searchName.Text.Trim(), "Computers");
             }
             else
             {
                 searchError.Text = "You can only search with only one parameter";
             }
         }
     }
     else if (cb.SelectedIndex == 1)
     {
         if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "")
         {
             searchError.Text = "Parameters can not be empty.";
         }
         else
         {
             if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "")
             {
                 dataGridView1.DataSource = SmartPhones.GetById(int.Parse(searchID.Text.Trim()), "SmartPhones");
             }
             else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "")
             {
                 dataGridView1.DataSource = SmartPhones.GetByName(searchName.Text.Trim(), "SmartPhones");
             }
             else
             {
                 searchError.Text = "You can only search with only one parameter";
             }
         }
     }
     else if (cb.SelectedIndex == 2)
     {
         if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "")
         {
             searchError.Text = "Parameters can not be empty.";
         }
         else
         {
             if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "")
             {
                 dataGridView1.DataSource = MusicBook.GetById(int.Parse(searchID.Text.Trim()), "MusicBook");
             }
             else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "")
             {
                 dataGridView1.DataSource = MusicBook.GetByName(searchName.Text.Trim(), "MusicBook");
             }
             else
             {
                 searchError.Text = "You can only search with only one parameter";
             }
         }
     }
     else
     {
         searchError.Text = "Please select a category.";
     }
 }