示例#1
0
 public void clearConfiguration()
 {
     RName.Clear();
     RAddress.Clear();
     RPhoneNumber.Clear();
     pictureBox1.Image = null;
     buttonSave.Text   = "Update";
 }
        private void AcceptRequest_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(RId.Text) && !string.IsNullOrWhiteSpace(RName.Text) && !string.IsNullOrWhiteSpace(RQuantity.Text))
            {
                try
                {
                    connection.Open();

                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "update requests set REQUEST_ID=@requestid,REQUEST_NAME=@requestname,REQUEST_QUANTATY=@requestquantity,REQUEST_STATUS=@requeststs where REQUEST_ID=@requestid";
                    cmd.Parameters.AddWithValue("@requestid", RId.Text);
                    cmd.Parameters.AddWithValue("@requestname", RName.Text);
                    cmd.Parameters.AddWithValue("@requestquantity", int.Parse(RQuantity.Text));
                    cmd.Parameters.AddWithValue("@requeststs", "checked");
                    cmd.Connection = connection;
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    string       sts = "'notchecked'";
                    MySqlCommand Com = new MySqlCommand($"Select * from requests where REQUEST_STATUS={sts} ", connection);

                    MySqlDataAdapter adp = new MySqlDataAdapter(Com);
                    DataSet          ds  = new DataSet();
                    adp.Fill(ds, "LoadRequests");
                    RequestsDataGrid.DataContext = ds;
                    connection.Close();
                    RId.Clear();
                    RName.Clear();
                    RQuantity.Clear();
                    MessageBox.Show("Request Reviewed", "Success");
                }
            }
            else
            {
                MessageBox.Show("please select a request !", "ERROR");
            }
        }