Click here to Skip to main content
15,893,487 members

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;
}
}
}