Hey guys,
I have some overloaded functions that I want to get out of my main form.cs - is there an easy way to do this? I know in C++ you can just #include somefile.h and whatnot, but I can't find a way to do this using C#? Basically, all I want is to move a large chunk of code from my main_form.cs to a separate code file, so my main_form.cs isn't so cluttered:
private void SQL_Update(string name, DateTime checkinDate, DateTime checkoutDate, string user, bool isCheckedOut)
{
cmd = new SqlCommand("UPDATE Laptops SET Name=@name, isCheckedOut = @ischeckedout, Checkout_Date=@checkout, Checkin_Date=@checkin, Checked_Out_By=@checkedoutby", conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@checkin", checkinDate.Date);
cmd.Parameters.AddWithValue("@checkout", checkoutDate.Date);
cmd.Parameters.AddWithValue("@checkedoutby", user);
cmd.Parameters.AddWithValue("@ischeckedout", isCheckedOut);
}
private void SQL_Update(string name, DateTime checkinDate, DateTime checkoutDate, string user, bool isCheckedOut, string authorizedby)
{
cmd = new SqlCommand("UPDATE Laptops SET Name=@name, isCheckedOut = @ischeckedout, Checkout_Date=@checkout, Checkin_Date=@checkin, Checked_Out_By=@checkedoutby, Authorized_By=@authorizedby", conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@checkin", checkinDate.Date);
cmd.Parameters.AddWithValue("@checkout", checkoutDate.Date);
cmd.Parameters.AddWithValue("@checkedoutby", user);
cmd.Parameters.AddWithValue("@authorizedby", authorizedby);
cmd.Parameters.AddWithValue("@ischeckedout", isCheckedOut);
}
private void SQL_Update(string name, DateTime checkinDate, DateTime checkoutDate, string user, bool isCheckedOut, string authorizedby, string notes)
{
cmd = new SqlCommand("UPDATE Laptops SET Name=@name, isCheckedOut = @ischeckedout, Checkout_Date=@checkout, Checkin_Date=@checkin, Checked_Out_By=@checkedoutby, Authorized_By=@authorizedby, Notes=@notes", conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@checkin", checkinDate.Date);
cmd.Parameters.AddWithValue("@checkout", checkoutDate.Date);
cmd.Parameters.AddWithValue("@checkedoutby", user);
cmd.Parameters.AddWithValue("@authorizedby", authorizedby);
cmd.Parameters.AddWithValue("@notes", notes);
cmd.Parameters.AddWithValue("@ischeckedout", isCheckedOut);
}
private void SQL_Update(string name, DateTime checkinDate, DateTime checkoutDate, string user, string notes, bool isCheckedOut)
{
cmd = new SqlCommand("UPDATE Laptops SET Name=@name, isCheckedOut = @ischeckedout, Checkout_Date=@checkout, Checkin_Date=@checkin, Checked_Out_By=@checkedoutby, Notes=@notes", conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@checkin", checkinDate.Date);
cmd.Parameters.AddWithValue("@checkout", checkoutDate.Date);
cmd.Parameters.AddWithValue("@checkedoutby", user);
cmd.Parameters.AddWithValue("@notes", notes);
cmd.Parameters.AddWithValue("@ischeckedout", isCheckedOut);
}
private void SQL_Update(DateTime checkinDate, bool isCheckedOut, string authorizedby)
{
cmd = new SqlCommand("UPDATE Laptops SET isCheckedOut = @ischeckedout, Checkin_Date=@checkin, Authorized_By=@authorizedby", conn);
cmd.Parameters.AddWithValue("@checkin", checkinDate.Date);
cmd.Parameters.AddWithValue("@ischeckedout", isCheckedOut);
cmd.Parameters.AddWithValue("@authorizedby", authorizedby);
}