Dear Taswar/all,
Many thanks for the reply.
I am testing in VisualStudio 2010 - in a project. I have the source code.
i had done some corrections in the code in methods - still the code is not working. Any inputs will be helpful.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace AssetApp
{
class Program
{
static void Main(string[] args)
{
bool value = true;
while (value)
{
getdisplay();
}
//Console.ReadLine();
//value = false;
}
private static bool getdisplay()
{
Console.WriteLine("-------------------------------------- ");
Console.WriteLine("---------------------------------------");
Console.Clear();
Console.WriteLine("----------Asset Application------------");
Console.WriteLine(" 1 IFMR Trust Asset ");
Console.WriteLine(" 2 Standby Laptop Register ");
Console.WriteLine(" 3 Scrap Register ");
Console.WriteLine(" 4 Purchase Register ");
Console.WriteLine(" 5 Service Call Report ");
Console.WriteLine(" 6 IT Helpdesk ");
Console.WriteLine(" 7 Exit ");
Console.WriteLine("---------------------------------------");
string input = Console.ReadLine();
switch (input)
{
case "1":
IFMRTrustAsset();
break;
case "2":
Console.WriteLine("Standy Laptop Register");
break;
case "3":
Console.WriteLine("Scrap Register");
break;
case "4":
Console.WriteLine("Purchase Register");
break;
case "5":
Console.WriteLine("Service call Report");
break;
case "6":
Console.WriteLine("IT Helpdesk");
break;
case "7":
return false;
default:
break;
}
return true;
}
private static void IFMRTrustAsset()
{
Console.WriteLine("------IFMR Trust Asset------------------------");
Console.WriteLine("Type the Department Name");
string departmentName = Console.ReadLine();
Console.WriteLine("Type the First Name");
string firstName = Console.ReadLine();
Console.WriteLine("Type the Last Name");
string lastName = Console.ReadLine();
Console.WriteLine("Type the User Name");
string userName = Console.ReadLine();
Console.WriteLine("Type the Model Number");
string modelNumber = Console.ReadLine();
Console.WriteLine("Type the AssetTypeID");
string assetTypeID = Console.ReadLine();
Console.WriteLine("Type the SerialNumber");
string serialNumber = Console.ReadLine();
//Console.WriteLine("Type the WarrantyStartDate");
//string warrantyStartDate = Console.ReadLine();
//Console.WriteLine("Type the WarrantyEndDate");
//string warrantyEndDate = Console.ReadLine();
Console.WriteLine("Company");
string company = Console.ReadLine();
Console.WriteLine("EngineerID");
string engineerID = Console.ReadLine();
Console.WriteLine("ITHelpdeskID");
string itHelpdeskID = Console.ReadLine();
Console.WriteLine("EmpID");
string empID = Console.ReadLine();
//Handshake
SqlConnection myNewConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\AssetApp.mdf;Integrated Security=True");
//open the database
myNewConnection.Open();
//create command
SqlCommand myCommand = myNewConnection.CreateCommand();
//using the stored procedue to update the database using parameters add
myCommand.CommandText = "InsertAsset";
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new SqlParameter("@DepartmentName", departmentName));
myCommand.Parameters.Add(new SqlParameter("@FirstName", firstName));
myCommand.Parameters.Add(new SqlParameter("@LastName", lastName));
myCommand.Parameters.Add(new SqlParameter("@UserName", userName));
myCommand.Parameters.Add(new SqlParameter("@ModelNumber", modelNumber));
myCommand.Parameters.Add(new SqlParameter("@AssetTypeID", int.Parse(assetTypeID)));
myCommand.Parameters.Add(new SqlParameter("@SerialNumber", serialNumber));
myCommand.Parameters.Add(new SqlParameter("@WarrantyStartDate", DateTime.Now));
myCommand.Parameters.Add(new SqlParameter("@WarrantyEndDate", DateTime.Now));
myCommand.Parameters.Add(new SqlParameter("@Company", company));
myCommand.Parameters.Add(new SqlParameter("@EngineerID", int.Parse(engineerID)));
myCommand.Parameters.Add(new SqlParameter("@ITHelpdeskID", int.Parse(itHelpdeskID)));
myCommand.Parameters.Add(new SqlParameter("@EmpID", int.Parse(empID)));
int recordsAffected = myCommand.ExecuteNonQuery();
if (recordsAffected == 1)
{
Console.WriteLine("Successful your entry");
}
else
{
Console.WriteLine("Your entry is not successful");
}
//SqlDataReader myDataReader;
//myDataReader = myCommand.ExecuteReader();
//while (myDataReader.Read())
//{
// Console.WriteLine(myDataReader[2] + "Testing " + myDataReader[3]);
// Console.ReadLine();
//}
myNewConnection.Close();
Console.WriteLine("");
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
//wooReader= wooCommand.ExecuteReader();
//while (wooReader.Read())
//{
// Console.WriteLine(wooReader[1] + " " + wooReader[2]);
//}
//wowConnection.Close();
//Console.ReadLine();
//create command
//create request
//use the data
//while (myDataReader != null)
// (
// SqlDataReader
// )
//close the connection
//Console.WriteLine("");
//Console.WriteLine("------------------------------");
//Console.WriteLine("Type the Asset Number");
//string AssetNumber = Console.ReadLine();
}
public static void StandbyLaptopRegister()
{
Console.WriteLine("-------------------------------");
Console.WriteLine("Select the Date & Time");
string DateTime = Console.ReadLine();
Console.WriteLine("");
}
}
}
No comments:
Post a Comment