16,021,125 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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'.