private void GetOrderBtn_Click(object sender, RoutedEventArgs e) { SecurityManagementSystemEngine.WorkOrderInformation newWorkOrder = new SecurityManagementSystemEngine.WorkOrderInformation(); newWorkOrder.id = GenerateId(); newWorkOrder.orderBy = orderByCB.Text; newWorkOrder.workDetails = workDetailsTxtbox.Text; newWorkOrder.assignTo = assignToCB.Text; newWorkOrder.orderdate = orderdatedateP.SelectedDate.Value; newWorkOrder.roomNo = roomNoTxtbox.Text; SecurityManagementSystemStorage.SecurityManagementSystemStorageInteraction.DoEnterWorkOrder(newWorkOrder); workorderTC.SelectedIndex = 0; }
private static List<WorkOrderInformation> QueryAllWorkOrderList() { List<WorkOrderInformation> WorkOrderList = new List<WorkOrderInformation>(); MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "Select * From workOrder ;"; MySql.Data.MySqlClient.MySqlDataReader msqlReader = msqlCommand.ExecuteReader(); while (msqlReader.Read()) { WorkOrderInformation WorkOrder = new WorkOrderInformation(); WorkOrder.id = msqlReader.GetString("id"); WorkOrder.orderBy = msqlReader.GetString("orderBy"); WorkOrder.workDetails = msqlReader.GetString("workDetails"); WorkOrder.assignTo = msqlReader.GetString("assignTo"); WorkOrder.orderdate = msqlReader.GetDateTime("orderDate"); WorkOrder.roomNo = msqlReader.GetString("status"); WorkOrderList.Add(WorkOrder); } } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } return WorkOrderList; }
public static void EditWorkOrder(WorkOrderInformation newUpdateWorkOrder) { MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "UPDATE workorder SET orderBy=@orderBy,workDetails=@workDetails,assignTo=@assignTo,orderDate=@orderDate,status=@status WHERE id=@id"; msqlCommand.Parameters.AddWithValue("@orderBy", newUpdateWorkOrder.orderBy); msqlCommand.Parameters.AddWithValue("@workDetails", newUpdateWorkOrder.workDetails); msqlCommand.Parameters.AddWithValue("@assignTo", newUpdateWorkOrder.assignTo); msqlCommand.Parameters.AddWithValue("@orderDate", newUpdateWorkOrder.orderdate); msqlCommand.Parameters.AddWithValue("@status", newUpdateWorkOrder.roomNo); msqlCommand.Parameters.AddWithValue("@id", newUpdateWorkOrder.id); msqlCommand.ExecuteNonQuery(); } catch (Exception er) { } finally { //always close the connection msqlConnection.Close(); } }
private static int DoRegisterNewWorkOrderindb(WorkOrderInformation NewworkOrder) { int returnVal = 0; MySql.Data.MySqlClient.MySqlConnection msqlConnection = OpenDbConnection(); try { //define the command reference MySql.Data.MySqlClient.MySqlCommand msqlCommand = new MySql.Data.MySqlClient.MySqlCommand(); //define the connection used by the command object msqlCommand.Connection = msqlConnection; msqlCommand.CommandText = "INSERT INTO workorder(id,orderBy,workDetails,assignTo,orderDate,status) " + "VALUES(@id,@orderBy,@workDetails,@assignTo,@orderDate,@status)"; msqlCommand.Parameters.AddWithValue("@id", NewworkOrder.id); msqlCommand.Parameters.AddWithValue("@orderBy", NewworkOrder.orderBy); msqlCommand.Parameters.AddWithValue("@workDetails", NewworkOrder.workDetails); msqlCommand.Parameters.AddWithValue("@assignTo", NewworkOrder.assignTo); msqlCommand.Parameters.AddWithValue("@orderDate", NewworkOrder.orderdate); msqlCommand.Parameters.AddWithValue("@status", NewworkOrder.roomNo); msqlCommand.ExecuteNonQuery(); returnVal = 1; } catch (Exception er) { returnVal = 0; } finally { //always close the connection msqlConnection.Close(); } return returnVal; }
public static int DoEnterWorkOrder(WorkOrderInformation NewWorkOrder) { return DoRegisterNewWorkOrderindb(NewWorkOrder); }