15,893,487 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 Javascript questions
View Visual Basic questions
View Python 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 Chathur (Top 11 by date)
Chathur
8-Jun-15 2:32am
View
@Jacob Himes, Thanks for your reply. Actually the environment that I'm working on is Oracle Applications and basicaly my adea is to create a pl sql package and call it from a scheduled concurrent progame daily basis. Now I've done the coding part but getting certificate validation failure as https is used. though i've added certificats to oracle wallet still have the same issue.
Chathur
22-May-15 7:32am
View
@Mehdi Gholam, Exactly. But this is actually an Oracle Application Framwork and from there I'm calling few 3rd party REST APIs. Our business logic resides in Oralce APIs (PL/SQL). Thats why I need to do the manipulation in PL/SQL Procedures before storing in database.
Chathur
25-May-14 12:51pm
View
Usually it is said that in composition containing objects should be private!
Chathur
18-Apr-14 6:12am
View
Thanks, I got the point. One thing to clarify. In your original answer, instantiation of 'controller' and 'main form' is in Mian() method of program.cs (var view = new FormMain();var controller = new Controller(view, new EmployeeManager(new DataService()));). Lets say if this form is a child form of a MDI form and if we have several forms like this, And these forms are loaded from the main MDI, where should we do the instantiation of these controllers and child forms?
Chathur
16-Apr-14 6:29am
View
If I eliminate controller class and if use MainForm's constructor to reference an EmployeeManger object as follows, Obviously now its not MVC but do you see any other draw backs ?
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var EmployeeManager= new EmployeeManager(new DataService());
var view = new FormMain(EmployeeManager);
Application.Run(view);
}
public partial class FormMain : Form
{
private Controller _controller;
public FormMain(EmployeeManager employeemanager)
{
InitializeComponent();
_employeemanager= employeemanager;
}
private void button1_Click(object sender, EventArgs e)
{
var newEmp = _employeemanager.SearchEmployee(txtEmployeeID.Text);
if(null == newEmp)
{
//Id is not found.
}
txtEmployeeName.Text = newEmp.EmployeeName;
txtEmployeeAddress.Text = newEmp.EmployeeAddress;
}
}
public class EmployeeManager
{
private DataService _ds;
public EmployeeManager(DataService DS)
{
_ds = DS;
}
public Employee SearchEmployee(string employeeID)
{
var dt = _ds.GetByEmployeeId(employeeID);
if (dt.Rows.Count > 0)
{
return new Employee(employeeID,
dt.Rows[0].ItemArray[1].ToString(),
dt.Rows[0].ItemArray[2].ToString());
}
return null;
}
//ADD DELETE UPDATE METHODS etc.
}
public class Employee
{
public string EmployeeID { get; set; }
public string EmployeeName { get; set; }
public string EmployeeAddress { get; set; }
public Employee(string employeeID, string employeeName, string employeeAddress)
{
EmployeeID = employeeID;
EmployeeName = employeeName;
EmployeeAddress = employeeAddress;
}
}
public class DataService
{
public DataTable GetByEmployeeId(string employeeID)
{
using (SqlConnection newCon = new SqlConnection(""))
{
SqlCommand Cmd = new SqlCommand("SELECT..WHERE emp_id=@employeeID", newCon);
Cmd.Parameters.Add("@employeeID", SqlDbType.VarChar).Value = employeeID;
newCon.Open();
SqlDataReader rdr = Cmd.ExecuteReader();
DataTable results = new DataTable();
results.Load(rdr);
return results;
}
}
}
Chathur
16-Apr-14 6:26am
View
Deleted
If I eliminate controller class and if use MainForm's constructor to reference an EmployeeManger object as follows, Obviously now its not MVC but do you see any other draw backs ?
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var EmployeeManager= new EmployeeManager(new DataService());
var view = new FormMain(EmployeeManager);
Application.Run(view);
}
public partial class FormMain : Form
{
private Controller _controller;
public FormMain(EmployeeManager employeemanager)
{
InitializeComponent();
_employeemanager= employeemanager;
}
private void button1_Click(object sender, EventArgs e)
{
var newEmp = _employeemanager.SearchEmployee(txtEmployeeID.Text);
if(null == newEmp)
{
//Id is not found.
}
txtEmployeeName.Text = newEmp.EmployeeName;
txtEmployeeAddress.Text = newEmp.EmployeeAddress;
}
}
public class EmployeeManager
{
private DataService _ds;
public EmployeeManager(DataService DS)
{
_ds = DS;
}
public Employee SearchEmployee(string employeeID)
{
var dt = _ds.GetByEmployeeId(employeeID);
if (dt.Rows.Count > 0)
{
return new Employee(employeeID,
dt.Rows[0].ItemArray[1].ToString(),
dt.Rows[0].ItemArray[2].ToString());
}
return null;
}
//ADD DELETE UPDATE METHODS etc.
}
public class Employee
{
public string EmployeeID { get; set; }
public string EmployeeName { get; set; }
public string EmployeeAddress { get; set; }
public Employee(string employeeID, string employeeName, string employeeAddress)
{
EmployeeID = employeeID;
EmployeeName = employeeName;
EmployeeAddress = employeeAddress;
}
}
public class DataService
{
public DataTable GetByEmployeeId(string employeeID)
{
using (SqlConnection newCon = new SqlConnection(""))
{
SqlCommand Cmd = new SqlCommand("SELECT..WHERE emp_id=@employeeID", newCon);
Cmd.Parameters.Add("@employeeID", SqlDbType.VarChar).Value = employeeID;
newCon.Open();
SqlDataReader rdr = Cmd.ExecuteReader();
DataTable results = new DataTable();
results.Load(rdr);
return results;
}
}
}
Chathur
15-Apr-14 23:59pm
View
Could you please clarify why you have put this code as follows instead of putting it in the constructor of FormMain? Also when this method is get invoked?
public void SetController(Controller controller)
{
_controller = controller;
}
Chathur
11-Apr-14 23:46pm
View
Thank you very much for your advice. Im under impression that I should use a separate class for db logic too. In my case I have several entity classes like Employee, Client etc. So should I use
a single class for db logic or a separate one for each entity class. Appreciate if you could you give some code. Chathur
Chathur
11-Apr-14 23:16pm
View
Thank you very much for your idea. In your example code you have separated data presentation. Like wise could you give me a code example to separate db logic too from BankAccount class? It will be highly appreciated. Also in my project I have several entity classes like Employee, Client etc. So for each class should I use separate class for db logic or a general one for all? Chathur.
Chathur
5-Mar-14 1:05am
View
Thank you for the advice. So I think its better to build the connection string dynamically and to create new connection when needed in method levels.
Chathur
5-Mar-14 0:40am
View
Thank you for the advice. Is this three-tier model a good approach to develop oo systems, in this case a payroll system?
Show More