Inheritance: System.Windows.Forms.DataGridView, IMetroControl
        //End variables

        //Constructor
        public frmShowController(MetroForm form, MetroGrid grid)
        {
            this.form = form;
            this.grid = grid;
            //Instantiate database.
            database = new Database(form);
        }
 //Validates the column of a certain grid with a field size of 30.
 //Checks to see if it is empty
 //Checks its length
 public bool validateEdit30(MetroGrid grid, int column)
 {
     string value;
     bool validateValue = false;
     //Loop through each row in the list.
     for (int i = 0; i < grid.Rows.Count; i++)
     {
         value = Convert.ToString(grid.Rows[i].Cells[column].Value);//Get value of cell[i, column]
         //Value cannot be empty.
         if (value != "")
         {
             //Value cannot exceed over 30.
             if (value.Length > 30)
             {
                 //Value's length is greater than 30.
                 return false;
             }
             //Value is less than 30.
             else
             {
                 validateValue = true;
             }
         }
         
         //Value is empty  
         else
         {                 
             return false;
         }
     }
     return validateValue;
 }
Esempio n. 3
0
        private void TreeView1_AfterSelect_1(object sender, TreeViewEventArgs e)
        {
            Padding pading = new Padding();

            pading.Top = 30;
            // MetroFramework.Controls.MetroTabControl a
            string filename = filenameTxt.Text;

            NodeName.Text = e.Node.Text;

            tabGridview           = new MetroFramework.Controls.MetroGrid();
            tabGridview.Name      = "tabGridView";
            tabGridview.Dock      = DockStyle.Fill;
            tabGridview.GridColor = Color.BurlyWood;

            GrdtabPage         = new MetroTabPage();
            GrdtabPage.Text    = e.Node.Text;
            GrdtabPage.Padding = pading;
            GrdtabPage.Controls.Add(tabGridview);



            metroTabControl2.Style       = MetroColorStyle.Blue;
            metroTabControl2.SelectedTab = GrdtabPage;
            metroTabControl2.Controls.Add(GrdtabPage);

            System.Data.DataTable GrdData = Reader.GetGridData(e.Node.Text);
            tabGridview.DataSource = GrdData;
            tabGridview.EditMode   = DataGridViewEditMode.EditProgrammatically;
        }
        public frmShowController(MetroForm form, MetroGrid grid, int reservationID)
        {
            this.form = form;
            this.grid = grid;
            this.reservationID = reservationID;

            database = new Database(form); //Instantiate database.
        }
        //Changes the font size of grids.
        public void changeFont(MetroGrid grid)
        {
            //Changes grid's column's header's font size to 10. 
            grid.ColumnHeadersDefaultCellStyle.Font = new Font("", 10.0f);
            //Changes grid's data's font size to 8.
            grid.Font = new Font("", 8.0f); 

        }
        //End variables

        //Constructor
        public frmReservationController(MetroGrid grid, MetroForm form)
        {
            this.grid = grid;
            this.form = form;

            //Instantiate database
            database = new Database(form);
        }
        //End variables

        //Constructor
        public frmEmployeeController(MetroForm form, MetroGrid grid)
        {
            this.form = form;
            this.grid = grid;
            //Start instantiation
            database = new Database(this.form);
            encryptionController = new frmEncryptionController();
            //End instantiation
        }
 public static void temizle(MetroGrid grid)
 {
     foreach (DataGridViewCell oneCell in grid.SelectedCells)
     {
         if (oneCell.Selected)
         {
             grid.Rows.RemoveAt(oneCell.RowIndex);
         }
     }
 }
        public frmTicketController(MetroForm form, MetroGrid grid, int reservationID)
        {
            this.form = form;
            this.grid = grid;
            
            //Start instantiation
            ticket = new Ticket();
            database = new Database(form);
            //End instantiation

            ticket.getSetReservationID = reservationID;
        }
        //End variables

        //Constructor
        public frmTicketController(MetroForm form, List<int> seatID, int showID, int customerID, MetroGrid grid)
        {
            this.showID = showID;
            this.seatID = seatID;
            this.form = form;
            this.grid = grid;
            this.customerID = customerID;

            //Start instantiations
            reservationController = new frmReservationController(form, customerID, seatID, showID);
            reservation = new Reservation(customerID, DateTime.Now.Date);
            database = new Database(form);
            ticket = new Ticket();
            //End instantiations
        }
Esempio n. 11
0
        private void CmdNew_Click(object sender, EventArgs e)
        {
            if (filenameTxt.Text != "")
            {
                filenameTxt.Text = "";
                NodeName.Text    = "";
                tabGridview      = new MetroGrid();
                tabGridview.Name = "tabGridView";
                tabGridview.Dock = DockStyle.Fill;

                treeView1.Nodes.Clear();
                treeView2.Nodes.Clear();
                GrdtabPage.Text = "";
                GrdtabPage.Controls.Clear();
                metroTabControl2.Controls.Clear();
                tabGridview.DataSource = null;
            }
        }
 //Validates the column of a certain grid with a field size of 11.
 //Checks to see if it is empty
 //Checks its length - it has to be 11.
 //Checks if it is a number
 public bool validateEdit11(MetroGrid grid, int column)
 {
     string value;
     bool validateValue = false;
     //Loop through each row in the grid.
     for (int i = 0; i < grid.Rows.Count; i++)
     {
         value = Convert.ToString(grid.Rows[i].Cells[column].Value); //Get value of cell[i, column]
         //Value cannot be empty.
         if (value != "")
         {
             //Value needs to be 11
             if (value.Length != 11)
             {
                 //Value's length is not 11.
                 return false;
             }
             //Value's length is 11
             else
             {
                 //Checks to see if it is a number
                 try
                 {
                     Int64.Parse(value);
                     validateValue = true;
                 }
                 //Value is not a number
                 catch
                 {
                     return false;
                 }
             }
         }
         //Value is empty.
         else
         {
             return false;
         }
     }
     
     return validateValue;
 }
Esempio n. 13
0
        /// <summary>
        /// saves the changes of a grid to database
        /// </summary>
        /// <param name="grid"></param>
        public void SaveGridChangesToDatabase(ref MetroFramework.Controls.MetroGrid grid)
        {
            CustomSqlConnection con = new CustomSqlConnection();

            if (con.ConnectError())
            {
                return;
            }
            DataTable changes = table.GetChanges();

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = new SqlCommand($"SELECT * FROM t_s_faecher", con.Con);

            SqlCommand insertCmd = new SqlCommand($"INSERT INTO t_s_faecher (f_kurzform, f_langform) VALUES (@subjectNameShort, @subjectNameLong)", con.Con);

            insertCmd.Parameters.Add("@subjectNameShort", SqlDbType.NVarChar, 64, "Kürzel");
            insertCmd.Parameters.Add("@subjectNameLong", SqlDbType.NVarChar, 256, "Langbezeichnung");

            adapter.InsertCommand = insertCmd;

            SqlCommand deleteCmd = new SqlCommand($"DELETE FROM t_s_faecher WHERE f_kurzform = @subjectNameShort", con.Con);

            deleteCmd.Parameters.Add("@subjectNameShort", SqlDbType.NVarChar, 64, "Kürzel");
            adapter.DeleteCommand = deleteCmd;

            SqlCommand updateCmd = new SqlCommand($"UPDATE t_s_faecher SET f_kurzform = @subjectNameShort, f_langform = @subjectNameLong WHERE f_id = @subjectId", con.Con);

            updateCmd.Parameters.Add("@subjectNameShort", SqlDbType.NVarChar, 64, "Kürzel");
            updateCmd.Parameters.Add("@subjectNameLong", SqlDbType.NVarChar, 256, "Langbezeichnung");
            updateCmd.Parameters.Add("@subjectId", SqlDbType.Int, 32, "ID");
            adapter.UpdateCommand = updateCmd;

            if (changes != null)
            {
                changes = noDuplicates(changes);
                adapter.Update(changes);
            }
        }
        //Fills the grid with data using the SQL statement.
        public void updateGrid(string DDL, MetroGrid grid)
        {
            //Start instantiation
            OleDbDataAdapter DA = new OleDbDataAdapter(DDL, getSetCon());
            DataTable DT = new DataTable();
            //End instantiation

            try
            {
                getSetCon().Open(); //Opens connection
                DA.Fill(DT);
            }
          
            catch (Exception ex)
            {
                MetroMessageBox.Show(form, "Unsuccessful \n" + ex.Message);
            }
            grid.DataSource = DT; //Sets the data source.
            DA.Update(DT); //Updates the data adpapter.

            con.Close(); //Closes con.
        }
Esempio n. 15
0
 public void EnableSorting(MetroGrid grid)
 {
     foreach (DataGridViewColumn column in grid.Columns)
     {
         column.SortMode = DataGridViewColumnSortMode.Automatic;
     }
 }
Esempio n. 16
0
 public void UpdateLastRow2Grid(MetroGrid grid,int index=-1)
 {
     if(index == -1)
         index = grid.Rows.Add();
     if(commands[commands.Count - 1].GetType() == typeof(Command_WD))
     {
         Command_WD c = (Command_WD)commands[commands.Count - 1];
         grid.Rows[index].Cells[0].ToolTipText = c.id.ToString();
         grid.Rows[index].Cells[1].Value = c.TextCommand;
         grid.Rows[index].Cells[2].Value = c.target_command_list[c.selectedTargetIndex].Target;
         grid.Rows[index].Cells[3].Value = c.Value;
     }
     else if (commands[commands.Count - 1].GetType() == typeof(Command_SK))
     {
         Command_SK c = (Command_SK)commands[commands.Count - 1];
         grid.Rows[index].Cells[0].ToolTipText = c.id;
         grid.Rows[index].Cells[1].Value = c.TextCommand;
         grid.Rows[index].Cells[4].Value = c.pattern.img;
     }
 }
        //Checks to see if they are entering a duplicate username
        public bool distinctUsername(MetroGrid grid)
        {
            List<string> usernames = new List<string>(); //Create new list
            //Loop through each row in the grid.
            for (int i = 0; i < grid.Rows.Count; i++)
            {
                //Adds all usernames to the list
                usernames.Add(Convert.ToString(grid.Rows[i].Cells[3].Value)); //Both customer and employee the usernames are in column "3"
            }

            //Creates a copy of the list with only distinct values
            if (usernames.Count != usernames.Distinct().Count()) //Checks to see if they both have the same amount of items.
            {
                return false;
            }
            //Unique username
            else
            {
                return true;
            }
        }
        //End variable

        //Constructor
        public frmDatePickerController(MetroGrid grid)
        {
            this.grid = grid;
        }
        public void SaveAsCSV(MetroGrid grid, string filelocation)
        {
            if (grid.RowCount != 0)
            {
                string value = "";
                DataGridViewRow dr = new DataGridViewRow();

                using (StreamWriter sw = new StreamWriter(File.Open(filelocation, FileMode.OpenOrCreate)))
                {

                    for (var i = 0; i < grid.Columns.Count; i++)
                    {
                        if (i > 0)
                        {
                            sw.Write(",");
                        }

                        sw.Write(grid.Columns[i].HeaderText);
                    }

                    sw.WriteLine();

                    for (var r = 0; r < grid.RowCount - 1; r++)
                    {
                        if (r > 0)
                        {
                            sw.WriteLine();
                        }

                        dr = grid.Rows[r];

                        for (var p = 0; p < grid.Columns.Count; p++)
                        {
                            value = dr.Cells[p].Value.ToString();
                            value = value + ",";

                            sw.Write(value);

                        }
                    }
                    
                    sw.Close();


                }
            }

        }
 //Validates the column of a certain grid with a field size of 40.
 //Checks to see if it is empty
 //Checks its length
 //Checks to see if it has "@"
 public bool validateEdit40(MetroGrid grid, int column)
 {
     string value;
     bool validateValue = false;
     //Loop through each row in the grid.
     for (int i = 0; i < grid.Rows.Count; i++)
     {
         value = Convert.ToString(grid.Rows[i].Cells[column].Value);//Get value of cell[i, column]
         //Value cannot be empty.
         if (value != "")
         {
             //Value cannot exceed over 40.
             if (value.Length > 40)
             {
                 //Value is greater than 40.
                 return false;
             }
             //Value does no exceed 40 characters.
             else
             {
                 try
                 {
                     //Checks to see if the value has correct email format.
                     var address = new MailAddress(value).Address;
                     validateValue = true;
                 }
                 //address is invalid
                 catch (FormatException)
                 {
                     return false;
                 }
             }
         }
         //Value is empty
         else
         {
             return false;
         }
     }
     return validateValue;
 }
        //End variables

        //Constructor
        public frmMovieController(MetroForm form, MetroGrid grid)
        {
            this.form = form;
            this.grid = grid;
            database = new Database(this.form); //Instantiate database
        }
 //Display show details.
 public void displayShowDetails(MetroGrid grid)
 {
     //Get all show details.
     string DDL = "Select * from show where show_ID = " + getShowID(Convert.ToDateTime(comboBox.SelectedItem)); 
     OleDbCommand command = new OleDbCommand(DDL, database.getSetCon());
     database.updateGrid(DDL, grid); //Display information in the grid.
 }
Esempio n. 23
0
 /// <summary>
 /// fills a datagridview with the subject data
 /// </summary>
 /// <param name="grid">the refering gridview</param>
 /// <param name="value"></param>
 public void FillGrid(ref MetroFramework.Controls.MetroGrid grid, object value = null)
 {
     table                      = FillObject();
     grid.DataSource            = table;
     grid.Columns["ID"].Visible = false;
 }
 //Display show information in the grid.
 public void displayShow(MetroGrid grid)
 {
     //SQL Statement getting all values from show using show ID.
     string DDL = "select * from show where show_id = " + showID;
     database.updateGrid(DDL, grid); //Displays show information in the grid.
 }
 //Displays reservation details.
 public void displayReservation(MetroGrid grid)
 {
     //Gets all information from the reservation table depending on the reservation ID.
     string DDL = "Select * from reservation where reservation_id = " + reservationID;
     database.updateGrid(DDL, grid); //Adds information in the grid.
 }