private void sarchButton_Click(object sender, EventArgs e) { string partsNumbe; partsNumbe = sarchPartsNumberTextBox.Text; PartsInformationClass parts = null; List <PartsInformationClass> partses = new List <PartsInformationClass>(); string connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); string queryString = "SELECT * FROM partsInformationTable WHERE partsNumber='" + partsNumbe + "'"; SqlCommand command = new SqlCommand(queryString, connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { parts = new PartsInformationClass(); parts.PartsName = (reader["partsName"]).ToString(); partsNameTextBox.Text = (reader["partsName"]).ToString(); parts.PartsNumber = (reader["partsNumber"]).ToString(); partsNumberTextBox.Text = (reader["partsNumber"]).ToString(); parts.PartsPrice = (reader["partsPrice"]).ToString(); partsPriceTextBox.Text = (reader["partsPrice"]).ToString(); parts.PartsQuentity = (reader["partsQuentity"]).ToString(); partsQuentityTextBox.Text = (reader["partsQuentity"]).ToString(); } MessageBox.Show("PrtsName=" + parts.PartsName + "\npartsNumber" + parts.PartsNumber + "\npartsPrice" + parts.PartsPrice + "\npartsQuentity" + parts.PartsQuentity); connection.Close(); }
public List <PartsInformationClass> GetpartInnformation() { PartsInformationClass parts = null; List <PartsInformationClass> partses = new List <PartsInformationClass>(); string connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); string queryString = "SELECT * FROM partsInformationTable"; SqlCommand command = new SqlCommand(queryString, connection); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { parts = new PartsInformationClass(); parts.PartsName = (reader["partsName"]).ToString(); parts.PartsNumber = (reader["partsNumber"]).ToString(); parts.PartsPrice = (reader["partsPrice"]).ToString(); parts.PartsQuentity = (reader["partsQuentity"]).ToString(); partses.Add(parts); } connection.Close(); return(partses); }
public void storePartsInformation(PartsInformationClass pertsInforObj) { string connectionString = @"server=DUET-559FE4FA51\SQLEXPRESS;integrated security = SSPI; database = VehicleInformationDB;"; SqlConnection connection = new SqlConnection(connectionString); connection.Open(); string insertString = "INSERT INTO partsInformationTable VALUES('" + pertsInforObj.PartsName + "','" + pertsInforObj.PartsNumber + "','" + pertsInforObj.PartsPrice + "','" + pertsInforObj.PartsQuentity + "')"; SqlCommand command = new SqlCommand(insertString, connection); command.ExecuteNonQuery(); connection.Close(); }
private void saveButton_Click(object sender, EventArgs e) { PartsInformationClass partsObj = new PartsInformationClass(); partsObj.PartsName = partsNameTextBox.Text; partsObj.PartsNumber = partsNumberTextBox.Text; partsObj.PartsPrice = partsPriceTextBox.Text; partsObj.PartsQuentity = partsQuentityTextBox.Text; PartsInformationGetway partObg = new PartsInformationGetway(); partObg.storePartsInformation(partsObj); MessageBox.Show("Information Save"); }