private void Selecting_Row(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; if (grid.SelectedRows.Count > 0) { List <POReceiptHeaderModel> rcvs = new List <POReceiptHeaderModel>(); // grid.SelectedRows.DataBoundItem; foreach (DataGridViewRow item in grid.SelectedRows) { try { POReceiptHeaderModel po = (POReceiptHeaderModel)item.DataBoundItem; rcvs.Add(po); } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (rcvs.Count != 0) { _view.rcvsSelected = rcvs; } } }
private void CancelJob(object sender, EventArgs e) { MetroGrid grd = sender as MetroGrid; JobEntityModel job = _view.jobSelected; if (grd.Rows.Count > 0) { if (job.ProcessFlag) { MessageBox.Show(string.Format("Cannot cancel this Job, because Job : {0} was Processed" , job.JobEntityName) , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult dialogResult = MessageBox.Show("Are you sure to Cancel this job.", "Please confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { foreach (DataGridViewRow dgr in grd.Rows) { JobTaskModel curr = (JobTaskModel)dgr.DataBoundItem; if (curr.Priority > 0) { curr.CancelFlag = true; curr.LastUpdateDate = DateTime.Now; _repository.UpdateTask(curr); } } _view.tasks = _repository.GetTasksByJobID(_view.jobSelected.JobEntityId); _view.bindingTasks.DataSource = _view.tasks; } } }
public void ObtenerListaEmpleados(ref MetroGrid grid) { grid.Rows.Clear(); using (SQLiteConnection conexionSQL = new SQLiteConnection(cadenaConexion)) { using (SQLiteCommand cmdConsulta = new SQLiteCommand("SELECT * FROM Empleados", conexionSQL)) { conexionSQL.Open(); using (SQLiteDataReader reader = cmdConsulta.ExecuteReader()) { while(reader.Read()) { int idx = grid.Rows.Add(); grid.Rows[idx].Cells["colCod"].Value = reader.GetInt32(0); grid.Rows[idx].Cells["colNombreCompleto"].Value = reader.GetString(1); grid.Rows[idx].Cells["colDUI"].Value = reader.GetString(2); grid.Rows[idx].Cells["colTipoUsuario"].Value = reader.GetInt32(3); grid.Rows[idx].Cells["colNombreUsuario"].Value = reader.GetString(4); grid.Rows[idx].Cells["colFechaCreacion"].Value = reader.GetDateTime(6); } reader.Close(); } } } }
public void AllAppointments(MetroGrid mgv, string username) { string doc = DocName(username); var sql = "select id,name,age,sex,date,time from appointment where doctor = '" + doc + "' and date = CONVERT(date, getdate());"; DataAccess.PopulateGridView(mgv, sql);; }
public WorkInOperationPrinter(MetroGrid dgv, MetroTextBox printerIDTB, MetroComboBox statusCB, MetroDateTime date) { Dgv = dgv; PrinterIDTB = printerIDTB; StatusCB = statusCB; Date = date; }
// Method GetManipulationsByRole public static void GetManipulationsByRole(MetroGrid grid, string role) { List <ManipulationRoleModelUI> rolesUIs = new List <ManipulationRoleModelUI>(); string originalPath = Application.StartupPath; string fileSQLite = originalPath + "\\Roles.db3"; if (!File.Exists(fileSQLite)) { SQLiteConnection.CreateFile("Roles.db3"); } string createRoles = @"CREATE TABLE IF NOT EXISTS [ROLES] ( [MANIPULATION] VARCHAR(20) NOT NULL, [ROLE] VARCHAR(50) NOT NULL ) "; string selectRoles = $"SELECT * FROM ROLES WHERE ROLE = '{role}'"; using (SQLiteConnection con = new SQLiteConnection("Data Source = Roles.db3")) { using (SQLiteCommand command = new SQLiteCommand(con)) { con.Open(); command.CommandType = System.Data.CommandType.Text; command.CommandText = createRoles; command.ExecuteNonQuery(); command.CommandText = selectRoles; using (SQLiteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { string description = Enum.GetValues(typeof(EnumRoles)).Cast <Enum>().Where(p => p.GetControlName().Equals(reader["MANIPULATION"].ToString())).Select(p => p.GetDescription()).FirstOrDefault(); rolesUIs.Add(new ManipulationRoleModelUI { Description = description, Manipulation = reader["MANIPULATION"].ToString() }); } } con.Close(); grid.DataSource = null; grid.DataSource = rolesUIs; grid.Columns["Manipulation"].Visible = false; } } }
public ModelPrinter(MetroGrid dgv, string printerID, string printerModelName, MetroComboBox pintrerFirmCb) { PrinterModelID = printerID; PrinterModelName = printerModelName; PrinterFirmCb = pintrerFirmCb; Dgv = dgv; }
private void ManagerResaltados(MetroGrid visor, Int32 fila, Color c) { //visor.Rows[fila].Cells[0].Style.BackColor = c; //visor.Rows[fila].Cells[1].Style.BackColor = c; //visor.Rows[fila].Cells[2].Style.BackColor = c; //https://es.stackoverflow.com/questions/60502/ocultar-teclado-virtual-de-windows-aplicaci%C3%B3n-escritorio-c for (int i = 0; i < visor.RowCount - 1; i++) { if (visor.Rows[i].Cells[2].Value.ToString() == "Ocupada") { visor.Rows[i].Cells[2].Style.BackColor = Color.LightCoral; //buutons 4 DataGridViewButtonCell A = new DataGridViewButtonCell(); A.Value = visor.Rows[i].Cells[2].Value.ToString(); A.Style.BackColor = Color.LightCoral; A.Style.ForeColor = Color.Red; visor.Rows[i].Cells[4] = A; } else if (visor.Rows[i].Cells[2].Value.ToString() == "Disponible") { DataGridViewButtonCell A = new DataGridViewButtonCell(); A.Value = visor.Rows[i].Cells[2].Value.ToString(); A.Style.BackColor = Color.YellowGreen; A.Style.ForeColor = Color.Red; visor.Rows[i].Cells[4] = A; } } }
/// <summary> /// Erschafft eine Vorschau von 10 Datensätzen der Importdaten und stellt diese in einer GridView dar. /// </summary> public void FillGridViewRows(ref MetroGrid grid, object value = null) { //grid.DataSource = null; dt.Clear(); readCSV(false); grid.DataSource = dt; }
public void FillGridAllBooks(ref MetroGrid gridBooks, int grade, object value = null) { DataTable table = FillObject(); bookHelper.FillGrid(ref gridBooks, true); SetMark(ref gridBooks, grade, table); }
public Image EdgeEmphasize(Image img, MetroGrid datagrid, int ver) { Bitmap bmp = new Bitmap(img); double[,] matrixEdge1 = new double[3, 3] { { -1, -1, -1 }, { -1, 9, -1, }, { -1, -1, -1 } }; double[,] matrixEdge2 = new double[3, 3] { { -1, -1, -1 }, { -1, 17, -1, }, { -1, -1, -1 } }; matrixEdge2 = MultMatrixNumb(matrixEdge2, coeff); double[,] matrixEdge3 = new double[3, 3] { { 0, -1, 0 }, { -1, 5, -1, }, { 0, -1, 0 } }; double[,] tempMatrix = new double[3, 3]; switch (ver) { case 1: tempMatrix = matrixEdge1; break; case 2: tempMatrix = matrixEdge2; break; case 3: tempMatrix = matrixEdge3; break; } FillGridView(datagrid, tempMatrix); bmp = FilterForImage(bmp, tempMatrix); return(bmp); }
internal static MetroGrid AddDefaultNuGetPackageFields(this MetroGrid grid) { grid.Columns.Add(new DataGridViewTextBoxColumn() { Name = "Title", HeaderText = "Title", DataPropertyName = "Title" }); grid.Columns.Add(new DataGridViewTextBoxColumn() { Name = "Id", HeaderText = "Id", DataPropertyName = "Id" }); grid.Columns.Add(new DataGridViewTextBoxColumn() { Name = "Authors", HeaderText = "Authors", DataPropertyName = "Authors" }); grid.Columns.Add(new DataGridViewTextBoxColumn() { Name = "Version", HeaderText = "Version", DataPropertyName = "Version" }); return(grid); }
public void AttachDataToGrid(MetroGrid incomeGrid, DataFields incomeType) { BindingSource bS = new BindingSource(); switch (incomeType) { case DataFields.KAF: break; case DataFields.YEAR: break; case DataFields.SEMESTER: break; case DataFields.DISC: bS.DataSource = dataBase.Discs; break; case DataFields.CYCLE: bS.DataSource = dataBase.Cycles; break; default: break; } incomeGrid.DataSource = bS; }
public static void highlightNalichieIspravnost(MetroGrid dataGrid) { MySqlConnection connection = new MySqlConnection(server.connectionStr); connection.Open(); string sqlQuery = File.ReadAllText(Application.StartupPath + @"..\..\..\Queries\highlightNalichie.sql"); MySqlCommand sqlCommand = new MySqlCommand(sqlQuery, connection); MySqlDataReader reader = sqlCommand.ExecuteReader(); while (reader.Read()) { string id = reader.GetString("id"); for (int i = 0; i < dataGrid.RowCount; i++) { if (Convert.ToString(dataGrid.Rows[i].Cells[0].Value) == id) { dataGrid.Rows[i].DefaultCellStyle.BackColor = Color.SpringGreen; } } } reader.Close(); connection.Close(); }
/// <summary> /// fills a gridview with the book data /// </summary> /// <param name="gridBooks"></param> /// <param name="subjectId"></param> /// <param name="isAdvancedSubject"></param> /// <param name="value"></param> public void FillGridAllBooks(ref MetroGrid gridBooks, int subjectId, bool isAdvancedSubject, object value = null) { DataTable table = FillObjectAdvancedSubject(isAdvancedSubject); helper.FillGrid(ref gridBooks, true); SetMark(ref gridBooks, subjectId, table); }
/// <summary> /// Füllt das Gridview zum Vergleich der benötigten und der in der .csv vorhandenen Daten /// </summary> /// <param name="grid"></param> /// <param name="target"></param> /// <param name="value"></param> public void FillColGrid(ref MetroGrid grid, string target, object value = null) { DataTable table = new DataTable(); if (target.Equals("SEK1")) { table.Columns.Add("Vorname"); table.Columns.Add("Nachname"); table.Columns.Add("Geburtsdatum"); table.Columns.Add("Klasse"); table.Columns.Add("FS2"); table.Columns.Add("Profil"); table.Columns.Add("Religionsunterricht"); } else if (target.Equals("SEK2")) { table.Columns.Add("Vorname"); table.Columns.Add("Nachname"); table.Columns.Add("Geburtsdatum"); table.Columns.Add("Klasse"); table.Columns.Add("LK1"); table.Columns.Add("LK2"); table.Columns.Add("Grundkurse"); } else if (target.Equals("FAECHER")) { table.Columns.Add("Kurzform"); table.Columns.Add("Langform"); } grid.DataSource = table; }
private void Selecting_Row(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; DataGridViewCellValidatingEventArgs erg = e as DataGridViewCellValidatingEventArgs; _view.currSelected = (CurrencyModel)grid.CurrentRow.DataBoundItem; }
public void GettingSelected <T>(MetroGrid metroGrid, int columnNo, T value) { Type typeT = typeof(T); if (typeT == typeof(int)) { for (int i = 0; i < metroGrid.RowCount; i++) { if (Convert.ToInt32(metroGrid.Rows[i].Cells[columnNo].Value) == Convert.ToInt32(value)) { metroGrid.Rows[i].Selected = true; } } } else if (typeT == typeof(string)) { for (int i = 0; i < metroGrid.RowCount; i++) { if (Convert.ToString(metroGrid.Rows[i].Cells[columnNo].Value) == Convert.ToString(value)) { metroGrid.Rows[i].Selected = true; } } } else if (typeT == typeof(DateTime)) { for (int i = 0; i < metroGrid.RowCount; i++) { if (Convert.ToDateTime(metroGrid.Rows[i].Cells[columnNo].Value) == Convert.ToDateTime(value)) { metroGrid.Rows[i].Selected = true; } } } }
// Method UpdateRole public static GlobalConstants.ResponseResult UpdateRole(string roleName, MetroGrid grid) { GlobalConstants.ResponseResult res = new GlobalConstants.ResponseResult(); int execute = 0; string originalPath = Application.StartupPath; string fileSQLite = originalPath + "\\Roles.db3"; if (!File.Exists(fileSQLite)) { SQLiteConnection.CreateFile("Roles.db3"); } string createRoles = @"CREATE TABLE IF NOT EXISTS [ROLES] ( [MANIPULATION] VARCHAR(20) NOT NULL, [ROLE] VARCHAR(50) NOT NULL ) "; using (SQLiteConnection con = new SQLiteConnection("Data Source = Roles.db3")) { using (SQLiteCommand command = new SQLiteCommand(con)) { con.Open(); command.CommandType = System.Data.CommandType.Text; command.CommandText = createRoles; command.ExecuteNonQuery(); command.CommandText = $"DELETE FROM ROLES WHERE ROLE = '{roleName}'"; command.ExecuteNonQuery(); for (int i = 0; i < grid.Rows.Count; i++) { command.CommandText = $"INSERT INTO ROLES(MANIPULATION, ROLE) VALUES('{grid["Manipulation", i].Value.ToString()}', '{roleName}')"; execute += command.ExecuteNonQuery(); } con.Close(); if (execute == grid.Rows.Count) { res.TypeResponse = GlobalConstants.EnumResponse.EditSuccess; } else { res.TypeResponse = GlobalConstants.EnumResponse.EditFail; } } } return(res); }
public CartrigeTest(MetroGrid dgvModel, MetroLabel catrigeID, MetroTextBox serialNumber, MetroTextBox catrigeModel) { DgvModel = dgvModel; SerialNumber = serialNumber; CatrigeModel = catrigeModel; CatrigeID = catrigeID; }
public void SaveGridChangesToDataBase(ref MetroGrid grid, ref DataTable table) { if (con.ConnectError()) { return; } DataTable changes = ReturnChanges(ref grid, ref table); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand($"SELECT * FROM {TableName}", con.Con); SqlCommand insertCmd = new SqlCommand($"INSERT INTO {TableName} ({FieldName}) VALUES (@FieldName)", con.Con); insertCmd.Parameters.Add("@FieldName", SqlDbType.NVarChar, 64, FieldName); adapter.InsertCommand = insertCmd; SqlCommand deleteCmd = new SqlCommand($"DELETE FROM {TableName} WHERE {FieldName} = @FieldName", con.Con); deleteCmd.Parameters.Add("@FieldName", SqlDbType.NVarChar, 64, FieldName); adapter.DeleteCommand = deleteCmd; SqlCommand updateCmd = new SqlCommand($"UPDATE {TableName} SET {FieldName} = @FieldName WHERE {FieldId} = @FieldId", con.Con); updateCmd.Parameters.Add("@FieldName", SqlDbType.NVarChar, 64, FieldName); updateCmd.Parameters.Add("@FieldId", SqlDbType.Int, 32, FieldId); adapter.UpdateCommand = updateCmd; if (changes == null) { return; } adapter.Update(changes); }
public WorkInCatrigeModel(MetroTextBox catrigeModelName, MetroGrid dgv, MetroComboBox colorCB, MetroComboBox printerModelCB) { CatrigeModelName = catrigeModelName; Dgv = dgv; ColorCB = colorCB; PrinterModelCB = printerModelCB; }
private void Adjust(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; List <POLineModel> temps = _repository.GetPOLineByPOID(_view.poLines.FirstOrDefault().PoHeaderId); if (grid.SelectedRows.Count > 0) { List <POLineModel> lines = new List <POLineModel>(); foreach (DataGridViewRow item in grid.Rows) { try { POLineModel line = (POLineModel)item.DataBoundItem; POLineModel temp = temps.Where(x => x.PoLineId == line.PoLineId).FirstOrDefault(); if (line.Quantity != temp.Quantity) { lines.Add(line); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (lines.Count != 0) { SaveLinesAdjust(lines); } } }
private void Selecting_Row(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; if (grid.SelectedRows.Count > 0) { List <POHeaderModel> pos = new List <POHeaderModel>(); // grid.SelectedRows.DataBoundItem; foreach (DataGridViewRow item in grid.SelectedRows) { try { int id = Convert.ToInt32(item.Cells[0].Value); POHeaderModel po = _view.list.Where(x => x.PoHeaderId == id).FirstOrDefault(); pos.Add(po); } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (pos.Count != 0) { _view.posSelected = pos; } } }
public static void PopulateGridView(MetroGrid m, string query) { var da = DataAccess.GetDataSet(query); m.AutoGenerateColumns = false; m.DataSource = da.Tables[0]; }
private void Make_TB(MetroGrid grid, dynamic dta, string sub) { foreach (var a in dta) { dr = dt.NewRow(); foreach (var b in a.GetType().GetProperties()) { if (b.GetValue(a) != null) { dr[sub + b.Name] = b.GetValue(a); } } dt.Rows.Add(dr); } grid.AutoGenerateColumns = false; foreach (DataGridViewColumn col in grid.Columns) { col.DataPropertyName = col.Name; } int i = 1; grid.DataSource = dt; foreach (DataGridViewRow rw in grid.Rows) { rw.Cells[0].Value = i; i++; } grid.Refresh(); }
public void ObtenerListaClientes(ref MetroGrid grid) { grid.Rows.Clear(); using (SQLiteConnection conexionSQL = new SQLiteConnection(cadenaConexion)) { using (SQLiteCommand cmdConsulta = new SQLiteCommand("SELECT * FROM Clientes", conexionSQL)) { conexionSQL.Open(); using (SQLiteDataReader reader = cmdConsulta.ExecuteReader()) { while (reader.Read()) { int idx = grid.Rows.Add(); grid.Rows[idx].Cells["colCodCliente"].Value = reader.GetInt32(0); grid.Rows[idx].Cells["colNombres"].Value = reader.GetString(1); grid.Rows[idx].Cells["colDUI"].Value = reader.GetString(2); grid.Rows[idx].Cells["colDireccion"].Value = reader.GetString(3); grid.Rows[idx].Cells["colTelefono"].Value = reader.GetString(4); grid.Rows[idx].Cells["colEmail"].Value = reader.GetString(5); } reader.Close(); } } } }
/// <summary> /// fills a grid with all the subject data /// </summary> /// <param name="gridSubjects"></param> /// <param name="grade"></param> /// <param name="value"></param> public void FillGridAllSubjects(ref MetroGrid gridSubjects, int grade, object value = null) { DataTable table = FillObject(); subjectHelper.FillGrid(ref gridSubjects); SetMark(ref gridSubjects, grade, table); }
private void Set_DueDate(object sender, EventArgs e) { using (CalendaForm frm = new CalendaForm()) { frm.ShowDialog(); if (frm.dateSeleted != null) { MetroGrid grd = sender as MetroGrid; if (grd.SelectedRows.Count > 0) { DialogResult dialogResult = MessageBox.Show("Are you sure to set date = " + frm.dateSeleted.ToLongDateString(), "Please confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { foreach (DataGridViewRow dgr in grd.SelectedRows) { RequisitionLineModel curr = (RequisitionLineModel)dgr.DataBoundItem; try { if (!curr.RejectFlag) { curr.DueDate = frm.dateSeleted; _repository.UpdatePRLine(curr); } } catch { } } Filter(null, null); } } } } }
private void OK_Click(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; if (grid.SelectedRows.Count > 0) { List <POLineModel> lines = new List <POLineModel>(); //grid.SelectedRows.DataBoundItem; foreach (DataGridViewRow item in grid.Rows) { try { if ((bool)item.Cells[0].Value) { POLineModel line = (POLineModel)item.DataBoundItem; lines.Add(line); } } catch { //MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (lines.Count != 0) { _view.linesSelected = lines; _view.CloseMe(); } } }