public bool Update(DataGridObject obj) { MySqlConnection conexao = MySQLConn.GetInstancia().GetConexao(); conexao.Open(); MySqlCommand command = new MySqlCommand(); command.Connection = conexao; command.CommandType = System.Data.CommandType.Text; try { command.CommandText = "update defeito SET Peca = @Peca , Solucao = @Solucao, DescricaoDefeito = @Sintoma , Causa = @Causa where Id = @Id;"; command.Parameters.AddWithValue("@Peca", obj.Peca); command.Parameters.AddWithValue("@Solucao", obj.Solucao); command.Parameters.AddWithValue("@Sintoma", obj.Sintoma); command.Parameters.AddWithValue("@Causa", obj.Causa); command.Parameters.AddWithValue("@Id", obj.Defeito_Id); command.ExecuteNonQuery(); conexao.Close(); statusOK = true; } catch (Exception e) { statusOK = false; conexao.Close(); throw e; } return(statusOK); }
public bool SalvarNovaSolucao(DataGridObject obj) { bool statusOk = false; Defeito d = new Defeito(); d.Causa = obj.Causa; d.DescricaoDefeito = obj.Sintoma; d.Peca = obj.Peca; d.Solucao = obj.Solucao; DefeitoDAO DAO = new DefeitoDAO(); var idNovoDefeito = DAO.Create(d); if (idNovoDefeito > 0) { EquipamentoHasDefeitoDAO HasDAO = new EquipamentoHasDefeitoDAO(); var gravado = HasDAO.Create(obj.EquipId, idNovoDefeito, ""); if (gravado) { statusOk = true; } } return(statusOk); }
private void btnEditarSolucao_Click(object sender, EventArgs e) { DataGridObject obj = new DataGridObject(); foreach (DataGridViewRow row in dtgSolucao.SelectedRows) { obj.EquipId = Convert.ToInt32(row.Cells["EquipId"].Value); obj.Defeito_Id = Convert.ToInt32(row.Cells["Defeito_Id"].Value); obj.Causa = row.Cells["Causa"].Value.ToString(); obj.Peca = row.Cells["Peca"].Value.ToString(); obj.Sintoma = row.Cells["Sintoma"].Value.ToString(); obj.Solucao = row.Cells["Solucao"].Value.ToString(); obj.Observacao = row.Cells["Observacao"].Value.ToString(); } if (editarSolucaoForm == null || editarSolucaoForm.IsDisposed == true) { editarSolucaoForm = new AdicionarSolucao(obj); editarSolucaoForm.Activate(); editarSolucaoForm.Enabled = true; editarSolucaoForm.Show(); } }
private void isSearch() { bool stillSearching = true; while (stillSearching == true) { var GetObject = new GetObjectsViewModel(); barCode = GetObject.getBarCode(); var Patient = GetObject.getPatientObject(barCode); if (Patient != null) { ObservableCollection <int> Quantity = new ObservableCollection <int>(); PrintName = Patient.Name; PrintIC = Patient.IC; foreach (Medicine _medicine in Patient.medicine) { var DataGrid = new DataGridObject(); DataGrid.DGMedName = _medicine.Name; DataGrid.DGUnit = _medicine.Unit; DataGrid.SelectedQuantity = 0; Quantity = QuantityLister(Int32.Parse(_medicine.Min), Int32.Parse(_medicine.Max), Int32.Parse(_medicine.Add)); DataGrid.DGQuantity = Quantity; DispatchService.Invoke(() => { this.DataGridList.Add(DataGrid); }); } stillSearching = false; canClear = true; } else { MessageBox.Show("TIADA DALAM REKOD", "Amaran", MessageBoxButton.OK, MessageBoxImage.Information); } } }
private void btnSalvaSolucao_Click(object sender, EventArgs e) { DataGridObject obj = new DataGridObject(); obj.EquipId = equipamentoId; obj.Peca = txbPeca.Text.Trim().ToUpper(); obj.Sintoma = txtDefeito.Text.Trim().ToUpper(); obj.Causa = txtCausa.Text.Trim().ToUpper(); obj.Solucao = txtSolucao.Text.Trim().ToUpper(); List <ValidationResult> listErros = new List <ValidationResult>(); ValidationContext contexto = new ValidationContext(obj); bool validado = Validator.TryValidateObject(obj, contexto, listErros, true); if (validado) { if (dadosPassados == null && equipamentoId > 0) { PesquisarEquipamentoController ctrl = new PesquisarEquipamentoController(); //adciono uma nova solução var salvo = ctrl.SalvarNovaSolucao(obj); if (salvo) { lbStatus.Text = "Novo defeito adicionando com sucesso!"; lbStatus.ForeColor = Color.SpringGreen; txbPeca.Clear(); txtCausa.Clear(); txtDefeito.Clear(); txtSolucao.Clear(); } else { lbStatus.Text = "Ocorreu um erro ao salvar novo defeito!"; lbStatus.ForeColor = Color.Red; } } else { //edito solução existente dadosPassados.Peca = txbPeca.Text.Trim().ToUpper(); dadosPassados.Causa = txtCausa.Text.Trim().ToUpper(); dadosPassados.Sintoma = txtDefeito.Text.Trim().ToUpper(); dadosPassados.Solucao = txtSolucao.Text.Trim().ToUpper(); PesquisarEquipamentoController ctrl = new PesquisarEquipamentoController(); bool editado = ctrl.EditarSolucao(dadosPassados); if (editado) { lbStatus.Text = "Editado com sucesso!"; lbStatus.ForeColor = Color.SpringGreen; txbPeca.Clear(); txtCausa.Clear(); txtDefeito.Clear(); txtSolucao.Clear(); dadosPassados = null; } else { lbStatus.Text = "Ocorreu um erro!"; lbStatus.ForeColor = Color.Red; } } } else { StringBuilder sb = new StringBuilder(); foreach (var erro in listErros) { sb.Append(erro.ErrorMessage + " "); } lbStatus.Text = sb.ToString(); lbStatus.ForeColor = Color.Red; } }
public AdicionarSolucao(DataGridObject obj) { InitializeComponent(); dadosPassados = obj; Inicialiar(); }
void AddFakeVariablesDebug() { dg_Variables.BeginningEdit -= dg_Variables_BeginningEdit; dg_Variables.BeginningEdit += dg_Variables_BeginningEdit_DEBUG; // datagrid objs DataGridObject obj = new DataGridObject() { Name = "Points" }; DataGridObject sphere = new DataGridObject() { Name = "Sphere" }; DataGridObject mesh = new DataGridObject() { Name = "Mesh" }; DataGridObject line = new DataGridObject() { Name = "Line" }; List <DataGridObject> objs = new List <DataGridObject>() { obj, sphere, line, mesh }; dg_Variables.ItemsSource = objs; // pnts PointsVisual3D points = new PointsVisual3D(); Random rand = new Random(); for (int i = 0; i < 10; i++) { Point3D p = new Point3D(rand.NextDouble(), rand.NextDouble(), rand.NextDouble()); points.Points.Add(p); } points.Size = PropertyServer.PointSize; _dict.Add("Points", points); hv.Items.Add(points); // sphere SphereVisual3D sph = new SphereVisual3D() { Center = new Point3D(0, 0, 0), Radius = 0.1, }; _dict.Add("Sphere", sph); hv.Items.Add(sph); // mesh MeshBuilder builder = new MeshBuilder(true, true); builder.AddTriangle(new Point3D(1, 1, 1), new Point3D(2, 2, 4), new Point3D(5, 3, 3)); MeshVisual3D m = new MeshVisual3D() { Mesh = new Mesh3D(builder.Positions, Enumerable.Range(0, builder.Positions.Count)) }; _dict.Add("Mesh", m); hv.Items.Add(m); // line LinesVisual3D l = new LinesVisual3D(); l.Points.Add(new Point3D(4, 5, 7)); l.Points.Add(new Point3D(4, 8, 5)); _dict.Add("Line", l); hv.Items.Add(l); }
private void BuildGrid() { pager = new MyDataGridPager(); pager.NumberRowsToDisplay = 10; DataGridObject dataGridObj = new DataGridObject(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString, "PatientAppointmentInformation"); DatabaseRowObject dbRowObject = new DatabaseRowObject(); dbRowObject.AddColumn("ApptDate", "Appointment Date", MyDataTypes.DATETIME, true, 35, false); dbRowObject.AddColumn("ApptId", "", MyDataTypes.GUID, true, 35, false); dbRowObject.AddColumn("RLU", "RLU", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("SP", "SP", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("KD1", "KD", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("LHT", "LHT", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("LV", "LV", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("KD2", "KD ", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("ImageBeforeTherapy", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("ImageAfterTherapy", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("TherapyPerformed", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("SessionGoals", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("Name", "", MyDataTypes.STRING, false, 0, true, "Therapists", "TherapistId", "Id"); dataGridObj.DatabaseRowObject = dbRowObject; if (IsPostBack == false) { Session["PatientHistorySortOrder"] = "DESC"; pager.Sort = MyDataSort.DESC; } else { if (Session["PatientHistorySortOrder"] != null) { if (Session["PatientHistorySortOrder"].ToString() == "DESC") { pager.Sort = MyDataSort.DESC; } else { pager.Sort = MyDataSort.ASC; } } } dataGridObj.AddWhereClauseArgument("PatientId", Session[CommonDefinitions.CommonDefinitions.PATIENT_ID].ToString()); LinkButton linkButtonPatient = null; LinkButton linkButtonApptDate = null; TableRow row = new TableRow(); TableCell cell = new TableCell(); linkButtonPatient = new LinkButton(); if ((Session["PatientFirstName"] != null) && (Session["PatientLastName"] != null)) { linkButtonPatient.Text = String.Format("{0} {1} DOB: {2}", Session["PatientFirstName"].ToString(), Session["PatientLastName"].ToString(), Session["PatientBirthDate"].ToString()); } linkButtonPatient.Command += linkButtonPatient_Command; linkButtonPatient.CommandArgument = Session["PatientId"].ToString(); cell.Controls.Add(linkButtonPatient); row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 7; row.Cells.Add(cell); PatientApptData.Rows.Add(row); DataTable appointmentInfo = dataGridObj.BuildTable(); DataRow dataRow = null; System.Collections.IEnumerator iter = null; if (appointmentInfo.Rows.Count == 0) { row = new TableRow(); cell = new TableCell(); Label label = new Label(); label.Text = "No Appointments Found"; cell.Controls.Add(label); row.Cells.Add(cell); PatientApptData.Rows.Add(row); } else { iter = appointmentInfo.Rows.GetEnumerator(); while (iter.MoveNext()) { row = new TableRow(); cell = new TableCell(); Image img = null; cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "RLU"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "SP"; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "KD1"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "LHT"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "LV"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "KD2"; row.Cells.Add(cell); PatientApptData.Rows.Add(row); dataRow = (DataRow)iter.Current; row = new TableRow(); cell = new TableCell(); linkButtonApptDate = new LinkButton(); linkButtonApptDate.Text = dataRow.ItemArray[0].ToString(); linkButtonApptDate.Command += linkButtonApptDate_Command; linkButtonApptDate.CommandArgument = dataRow.ItemArray[dbRowObject.ColumnIndex("ApptId")].ToString(); cell.Controls.Add(linkButtonApptDate); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("RLU")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("SP")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("KD1")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("LHT")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("LV")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("KD2")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); PatientApptData.Rows.Add(row); row = new TableRow(); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("Name")].ToString();; cell.VerticalAlign = VerticalAlign.Top; row.Cells.Add(cell); cell = new TableCell(); cell.ColumnSpan = 3; img = new Image(); img.ImageUrl = dataRow.ItemArray[dbRowObject.ColumnIndex("ImageBeforeTherapy")].ToString(); img.ImageAlign = ImageAlign.Middle; img.Width = IMAGE_WIDTH; img.Height = IMAGE_HEIGHT; cell.HorizontalAlign = HorizontalAlign.Left; cell.Controls.Add(img); row.Cells.Add(cell); cell = new TableCell(); cell.ColumnSpan = 3; cell.Text = " "; cell = new TableCell(); cell.ColumnSpan = 3; img = new Image(); img.ImageUrl = dataRow.ItemArray[dbRowObject.ColumnIndex("ImageAfterTherapy")].ToString(); img.ImageAlign = ImageAlign.Middle; img.Width = IMAGE_WIDTH; img.Height = IMAGE_HEIGHT; cell.HorizontalAlign = HorizontalAlign.Left; cell.Controls.Add(img); row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 7; row.Cells.Add(cell); PatientApptData.Rows.Add(row); /// therapy performed row = new TableRow(); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Therapy Performed"; cell.ColumnSpan = 5; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Session Goals"; cell.ColumnSpan = 5; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); PatientApptData.Rows.Add(row); row = new TableRow(); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("TherapyPerformed")].ToString(); cell.ColumnSpan = 5; row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("SessionGoals")].ToString(); cell.ColumnSpan = 5; row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer for (int spacercount = 1; spacercount <= 2; spacercount++) { row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 10; row.Cells.Add(cell); PatientApptData.Rows.Add(row); } } } }
public List <DataGridObject> readByCriteria(String criteria) { MySqlConnection conexao = MySQLConn.GetInstancia().GetConexao(); conexao.Open(); List <DataGridObject> listObjs = null; try { listObjs = new List <DataGridObject>(); MySqlCommand command = new MySqlCommand(); command.Connection = conexao; command.CommandType = System.Data.CommandType.Text; command.CommandText = "SELECT tb.Id as Equipamento_Id,tb.Marca as Marca ,tb.Tipo as Tipo, tb.Modelo as Modelo, equipamento_has_defeito.Observacao as Obs, defeito.Id as Defeito_Id ," + " defeito.DescricaoDefeito as Sintoma ,defeito.Peca as Peca,defeito.Causa as Causa ,defeito.Solucao as Solucao FROM " + "(SELECT equipamento.Id as Id, modelo.Modelo as Modelo,marca.Nome as Marca,tipoequipamento.Tipo as Tipo FROM equipamento " + "join modelo on equipamento.Modelo_Id = modelo.Id JOIN marca ON equipamento.Marca_Id = marca.Id " + "JOIN tipoequipamento ON equipamento.TipoEquipamento_Id = tipoequipamento.Id where modelo.Modelo = @criteria) " + "tb join equipamento_has_defeito ON tb.Id = equipamento_has_defeito.Equipamento_Id JOIN defeito ON equipamento_has_defeito.Defeito_Id = defeito.Id;"; command.Parameters.AddWithValue("@criteria", criteria); MySqlDataReader dr = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection); if (dr.HasRows) { DataGridObject dto = new DataGridObject(); while (dr.Read()) { dto.Causa = (string)dr["Causa"]; dto.Defeito_Id = Convert.ToInt32(dr["Defeito_Id"]); dto.EquipId = Convert.ToInt32(dr["Equipamento_Id"]); dto.Marca = (string)dr["Marca"]; dto.Modelo = (string)dr["Modelo"]; dto.Observacao = (string)dr["Obs"]; dto.Peca = (string)dr["Peca"]; dto.Sintoma = (string)dr["Sintoma"]; dto.Solucao = (string)dr["Solucao"]; dto.Tipo = (string)dr["Tipo"]; listObjs.Add(dto); dto = new DataGridObject(); } } } catch (Exception e) { listObjs = null; throw e; } return(listObjs); }
public bool EditarSolucao(DataGridObject obj) { DefeitoDAO DAO = new DefeitoDAO(); return(DAO.Update(obj)); }
public void LoadGrid() { DatabaseRowObject.DatabaseColumnObject databaseColumnObj = null; dataGridObject = new DataGridObject(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString, "PatientInformation"); databaseRowObject = new DatabaseRowObject(); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "Id"; databaseColumnObj.DataGridColumnName = "Id"; databaseColumnObj.DataType = MyDataTypes.INTEGER; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = true; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "FirstName"; databaseColumnObj.DataGridColumnName = "First Name"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "LastName"; databaseColumnObj.DataGridColumnName = "Last Name"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "BirthDate"; databaseColumnObj.DataGridColumnName = "BirthDate"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.DisplayType = MyDisplayTypes.DATE; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "EmailAddress"; databaseColumnObj.DataGridColumnName = "Email Address"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "TelephoneNumber"; databaseColumnObj.DataGridColumnName = "Telephone Number"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); dataGridObject.DatabaseRowObject = databaseRowObject; dataGridObject.FillToCompletePage = true; dataGridObject.PageNumber = 1; dataGridObject.NumberRowsToDisplay = 15; pager = new MyDataGridPager(); pager.AddColumn("Id", 15); pager.AddColumn("First Name", 25); pager.AddColumn("Last Name", 250); pager.AddColumn("Email Address", 250); pager.AddColumn("Telephone Number", 100); if (txtBoxPatientFirstName.Text.Length > 0) { dataGridObject.AddWhereClauseArgument("FirstName", txtBoxPatientFirstName.Text); } if (txtBoxPatientLastName.Text.Length > 0) { dataGridObject.AddWhereClauseArgument("LastName", txtBoxPatientLastName.Text); } if (IsPostBack == false) { dataGridObject.PageNumber = 1; Session["PatientList_PageNumber"] = "1"; } else { dataGridObject.PageNumber = Int32.Parse(Session["PatientList_PageNumber"].ToString()); } patientlistgridview.DataSource = dataGridObject.BuildTable(); patientlistgridview.RowDataBound += Patientlistgridview_RowDataBound; patientlistgridview.SelectedIndexChanged += Patientlistgridview_SelectedIndexChanged; patientlistgridview.DataBind(); if (dataGridObject.NumberOfCompletedPages == 0) { btnNextPAge.Enabled = false; } else { btnNextPAge.Enabled = true; } }