System::Void btnSaveOrder_Click(System::Object * sender, System::EventArgs * e)
{
String *strCustomerName = this->txtCustomerName->Text;
if( strCustomerName->Equals(S"") )
{
MessageBox::Show(S"You must provide a name for the customer");
return;
}
String *strOrderDate = this->dtpOrderDate->Value.ToString(S"d");
String *strOrderTime = this->dtpOrderTime->Value.ToString(S"t");
String *strNewRepairOrder = String::Concat(S"INSERT INTO RepairOrders(OrderDate, "
S"OrderTime, CustomerName, Address, "
S"City, State, ZIPCode, Make, Model, "
S"CarYear, ProblemDescription, PartName1, "
S"UnitPrice1, Quantity1, SubTotal1, "
S"PartName2, UnitPrice2, Quantity2, "
S"SubTotal2, PartName3, UnitPrice3, "
S"Quantity3, SubTotal3, PartName4, "
S"UnitPrice4, Quantity4, SubTotal4, "
S"PartName5, UnitPrice5, Quantity5, "
S"SubTotal5, JobPerformed1, JobPrice1, "
S"JobPerformed2, JobPrice2, JobPerformed3, "
S"JobPrice3, JobPerformed4, JobPrice4, "
S"JobPerformed5, JobPrice5, TotalParts, "
S"TotalLabor, TaxRate, TaxAmount, "
S"OrderTotal, Recommendations) "
S"VALUES('", strOrderDate, S"', '", strOrderTime,
S"', '", strCustomerName, S"', '", this->txtAddress->Text,
S"', '", this->txtCity->Text, S"', '", this->txtState->Text,
S"', '", this->txtZIPCode->Text, S"', '", this->txtMake->Text,
S"', '", this->txtModel->Text, S"', '", this->txtCarYear->Text,
S"', '", this->txtProblem->Text, S"', '", this->txtPartName1->Text,
S"', '", this->txtUnitPrice1->Text, S"', '", this->txtQuantity1->Text,
S"', '", this->txtSubTotal1->Text, S"', '", this->txtPartName2->Text,
S"', '", this->txtUnitPrice2->Text, S"', '", this->txtQuantity2->Text,
S"', '", this->txtSubTotal2->Text, S"', '", this->txtPartName3->Text,
S"', '", this->txtUnitPrice3->Text, S"', '", this->txtQuantity3->Text,
S"', '", this->txtSubTotal3->Text, S"', '", this->txtPartName4->Text,
S"', '", this->txtUnitPrice4->Text, S"', '", this->txtQuantity4->Text,
S"', '", this->txtSubTotal4->Text, S"', '", this->txtPartName5->Text,
S"', '", this->txtUnitPrice5->Text, S"', '", this->txtQuantity5->Text,
S"', '", this->txtSubTotal5->Text, S"', '", this->txtJobPerformed1->Text,
S"', '", this->txtJobPrice1->Text, S"', '", this->txtJobPerformed2->Text,
S"', '", this->txtJobPrice2->Text, S"', '", this->txtJobPerformed3->Text,
S"', '", this->txtJobPrice3->Text, S"', '", this->txtJobPerformed4->Text,
S"', '", this->txtJobPrice4->Text, S"', '", this->txtJobPerformed5->Text,
S"', '", this->txtJobPrice5->Text, S"', '", this->txtTotalParts->Text,
S"', '", this->txtTotalLabor->Text, S"', '", this->txtTaxRate->Text,
S"', '", this->txtTaxAmount->Text, S"', '", this->txtTotalOrder->Text,
S"', '", this->txtRecommendations->Text, S"');");
System::Data::SqlClient::SqlConnection *conDatabase = new
System::Data::SqlClient::SqlConnection(
S"Data Source=(local);Database='CPAS';Integrated Security=yes");
System::Data::SqlClient::SqlCommand *cmdDatabase = new
System::Data::SqlClient::SqlCommand(strNewRepairOrder, conDatabase);
conDatabase->Open();
cmdDatabase->ExecuteNonQuery();
conDatabase->Close();
}
|