protected void GrdPatientLabs_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item is Telerik.Web.UI.GridEditableItem) { try { Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem; var ObjId = editedItem.GetDataKeyValue("Id"); int Id = ObjId != null ? (int)ObjId : 0; Data.DataProvider.Instance().DeleteLaboratory(Id); DisplayAlert("El exámen de laboratorio fue eliminado correctamente", "Eliminar Exámen", "Info"); GrdPatientLabs.Rebind(); GrdLabDetails.Rebind(); TxtObservation.Text = string.Empty; } catch (Exception ex) { e.Canceled = true; DisplayAlert(ex); } } }
protected void BtnProcess_Click(object sender, EventArgs e) { try { int LabId = 0; foreach (Telerik.Web.UI.GridDataItem item in GrdPatientLabs.SelectedItems) { LabId = int.Parse(item["Id"].Text); } if (LabId == 0) { DisplayAlert("Debe seleccionar primero un laboratorio", "Seleccionar Laboratorio", "Alert"); return; } Data.DataProvider.Instance().SetClosedLaboratory(LabId, UserId); GrdPatientLabs.Rebind(); GrdLabDetails.Rebind(); TxtObservation.Text = string.Empty; TxtObservation.Enabled = false; BtnSaveObservation.Enabled = false; BtnProcess.Enabled = false; DisplayAlert("Exámen de laboratorio procesado correctamente.", "Exámen Procesado", "Info"); } catch (Exception ex) { DisplayAlert(ex); } }
protected void GrdPatientLabs_PreRender(object sender, EventArgs e) { if (RowIndex > -1) { Telerik.Web.UI.GridDataItem item = (Telerik.Web.UI.GridDataItem)GrdPatientLabs.Items[RowIndex]; item.Selected = true; RowIndex = -1; GrdLabDetails.Rebind(); } }
protected void BtnClearResult_Click(object sender, EventArgs e) { GrdPatientLabs.Rebind(); GrdLabDetails.Rebind(); TxtObservation.Text = string.Empty; TxtObservation.Enabled = false; BtnSaveObservation.Enabled = false; BtnProcess.Enabled = false; BtnExport.Enabled = false; }
protected void GrdPatientLabs_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item != null) { if (e.Item.ItemIndex >= 0) { string Status = string.Empty; string Observation = string.Empty; e.Item.Selected = true; foreach (Telerik.Web.UI.GridDataItem item in GrdPatientLabs.SelectedItems) { Status = item["Status"].Text; TxtObservation.Text = item["Observation"].Text.Replace(" ", ""); if (Status == "Procesado") { TxtObservation.Enabled = false; BtnSaveObservation.Enabled = false; BtnProcess.Enabled = false; BtnExport.Enabled = true; } else { TxtObservation.Enabled = true; BtnSaveObservation.Enabled = true; BtnProcess.Enabled = true; BtnExport.Enabled = false; } } } else { if (e.CommandName == "RebindGrid") { GrdPatientLabs.Rebind(); GrdLabDetails.Rebind(); TxtObservation.Text = string.Empty; TxtObservation.Enabled = false; BtnSaveObservation.Enabled = false; BtnProcess.Enabled = false; BtnExport.Enabled = false; } } } GrdLabDetails.Rebind(); }
protected void GrdLabDetails_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item is Telerik.Web.UI.GridEditableItem) { try { Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem; var ObjId = editedItem.GetDataKeyValue("Id"); int Id = ObjId != null ? (int)ObjId : 0; Data.DataProvider.Instance().DeleteLaboratoryDetail(Id); DisplayAlert("Resultado eliminado correctamente", "Eliminar Resultado", "Info"); GrdLabDetails.Rebind(); } catch (Exception ex) { e.Canceled = true; DisplayAlert(ex); } } }
protected void GrdLabDetails_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item is Telerik.Web.UI.GridEditableItem) { try { Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem; int Id = 0; string LabDetail = string.Empty; string LabResult = string.Empty; string LabReference = string.Empty; string LabUnit = string.Empty; bool Remark = false; var objId = editedItem.GetDataKeyValue("Id"); Id = objId != null ? (int)objId : 0; System.Collections.Hashtable newValues = new System.Collections.Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); foreach (System.Collections.DictionaryEntry item in newValues) { switch (item.Key.ToString()) { case "LabDetail": LabDetail = item.Value.ToString(); break; case "LabResult": LabResult = item.Value.ToString(); break; case "LabReference": LabReference = item.Value.ToString(); break; case "LabUnit": LabUnit = item.Value.ToString(); break; case "Remark": Remark = bool.Parse(item.Value.ToString()); break; } } Data.DataProvider.Instance().SetLaboratoryDetail(0, LabDetail, LabResult, LabReference, LabUnit, Remark, UserId, Id); GrdLabDetails.Rebind(); DisplayAlert("Resultado actualizado correctamente", "Resultado Actualizado", "Info"); } catch (Exception ex) { e.Canceled = true; DisplayAlert(ex); } } }
protected void GrdLabDetails_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item is Telerik.Web.UI.GridEditableItem) { try { int LabId = 0; string LabDetail = string.Empty; string LabResult = string.Empty; string LabReference = string.Empty; string LabUnit = string.Empty; bool Remark = false; foreach (Telerik.Web.UI.GridDataItem item in GrdPatientLabs.SelectedItems) { LabId = int.Parse(item["Id"].Text); } if (LabId == 0) { DisplayAlert("Debe seleccionar un laboratorio primero.", "Alerta", "Alert"); e.Canceled = true; return; } Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem; System.Collections.Hashtable newValues = new System.Collections.Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); foreach (System.Collections.DictionaryEntry item in newValues) { switch (item.Key.ToString()) { case "LabDetail": LabDetail = item.Value.ToString(); break; case "LabResult": LabResult = item.Value.ToString(); break; case "LabReference": LabReference = item.Value.ToString(); break; case "LabUnit": LabUnit = item.Value.ToString(); break; case "Remark": Remark = bool.Parse(item.Value.ToString()); break; } } Data.DataProvider.Instance().SetLaboratoryDetail(LabId, LabDetail, LabResult, LabReference, LabUnit, Remark, UserId); GrdLabDetails.Rebind(); DisplayAlert("Resultado agregado correctamente", "Laboratorio Agregado", "Info"); } catch (Exception ex) { e.Canceled = true; DisplayAlert(ex); } } }
protected void GrdPatientLabs_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.Item is Telerik.Web.UI.GridEditableItem) { try { Telerik.Web.UI.GridEditableItem editedItem = e.Item as Telerik.Web.UI.GridEditableItem; int Id = 0; string LabName = string.Empty; int DoctorId = 0; string Observation = string.Empty; var objId = editedItem.GetDataKeyValue("Id"); Observation = GrdPatientLabs.Items[editedItem.ItemIndex]["Observation"].Text.Replace(" ", string.Empty); Id = objId != null ? (int)objId : 0; System.Collections.Hashtable newValues = new System.Collections.Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); foreach (System.Collections.DictionaryEntry item in newValues) { switch (item.Key.ToString()) { case "LabName": LabName = item.Value.ToString(); break; case "DoctorId": DoctorId = item.Value != null?int.Parse(item.Value.ToString()) : 0; break; case "Observation": Observation = item.Value.ToString(); break; } } if (DoctorId == 0) { DisplayAlert("Debe seleccionar un medico", "Alerta", "Alert"); return; } Data.DataProvider.Instance().SetLaboratory(0, DoctorId, LabName, Observation, UserId, Id); TxtObservation.Text = Observation; GrdPatientLabs.Rebind(); GrdLabDetails.Rebind(); BtnSaveObservation.Enabled = false; BtnProcess.Enabled = false; DisplayAlert("Laboratorio actualizado correctamente", "Laboratorio Actualizado", "Info"); } catch (Exception ex) { e.Canceled = true; DisplayAlert(ex); } } }