Click here to Skip to main content
16,021,125 members

Comments by Kutub1987 (Top 3 by date)

Kutub1987 5-Dec-11 10:53am View    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PatientPrescription.DAO.DAL;
using PatientPrescription.UI;
using PatientPrescription.DAO.GATEWAY;
using PatientPrescription.Utility;
using PatientPrescription.BLL;

namespace PatientPrescription.UI
{
public partial class MedicationUI : Form
{
AppMessage appMes;
MedicationGateway objectCls ;
public string testType, testName;
Patient patientMed;
string type;
private List<object> listMedName;
private List<medication> objMedication;
private List<Object> objdeletedMed;
private int _patientID;
private int _prescriptionID;
private BindingSource objMedSource = new BindingSource();
public MedicationUI()
{
objectCls = new MedicationGateway();
InitializeComponent();
FillTreeView();
}
public MedicationUI(Patient patient, string typeFrom,int patinetID,int PrescriptionID)
{
_patientID = patinetID;
_prescriptionID = PrescriptionID;
objectCls = new MedicationGateway();
patientMed = new Patient();
patientMed = patient;
type = typeFrom;
InitializeComponent();
FillTreeView();
}
private void btnClose_Click(object sender, EventArgs e)
{
if (appMes.Id == -2)
{
DialogResult answer = MessageBox.Show("You Didn't Save/Enter Any Medicine, Really Want to Close?", "Attention", MessageBoxButtons.YesNo);
if (answer == DialogResult.Yes)
{
this.Close();
PrescriptionUI pUI = new PrescriptionUI(patientMed, "medicine");
pUI.Show();
}
}
else
{
PrescriptionUI prescriptionUI = new PrescriptionUI(patientMed, "medicine");
prescriptionUI.Show();
this.Close();
}
}

private void btnSave_Click(object sender, EventArgs e)
{
listMedName = new List<object>();
foreach (TreeNode trNode in trvMedicine.Nodes)
{
if (trNode.Checked == true)
{
foreach (TreeNode childNode in trNode.Nodes)
{
if (childNode.Checked == true)
{
listMedName.Add(childNode.Text);
}
}
}
else
{
MessageBox.Show("No Parent Medicine was selected","Error",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1);
return;
}
}
objMedication = new List<medication>();
objMedication = objectCls.GetSelectedMedicine(listMedName);

objMedSource.DataSource = objMedication;
dtgMedicine.DataSource = objMedSource;
dtgMedicine.Columns["ID"].Visible = false;
dtgMedicine.Columns["PID"].Visible = false;
dtgMedicine.Columns["DoseID"].Visible = false;
dtgMedicine.Columns["TypeID"].Visible = false;
dtgMedicine.Columns["TypeDesc"].ReadOnly = true;
dtgMedicine.Columns["Name"].ReadOnly = true;
}
private void lnkClickToAddMore_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{

MedicationListSetupUI objMedicationListSetupUI = new MedicationListSetupUI();
objMedicationListSetupUI.Show();
//this.Close();
}
public void FillTreeView()
{
DataSet dsTreeViewParents;
DataSe
Kutub1987 5-Dec-11 3:50am View    
Actually i have used binding source to display some information in the data grid view as data in the view might be changed(a row might be deleted or column of a row might be edited) by the user. Now when i want to save the data i cant access through data grid views' data source, so i tried this way. Please let me know if you have any suggestions.
Kutub1987 4-Dec-11 22:53pm View    
using this dttable = ((DataTable)(dtgMedicine.DataSource)).Clone();
i have the following error : -
Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'System.Data.DataTable'.