Esempio n. 1
0
        public CustomerDetails(string Id)
        {
            InitializeComponent();
            ClientFile = Path.GetDirectoryName(Variables.CompanyFile) + "\\SurveyToolbox\\Customers.track";
            XDocument doc       = XDocument.Load(ClientFile);
            var       Customers = doc.Root.Elements("Customer");
            var       Customer  = Customers.FirstOrDefault(RId => RId.Attribute("Id").Value == Id);

            if (Customer == null)
            {
                MessageBox.Show("The indicated customer could not be found. Please contact the admin.");
                this.Close();
                return;
            }
            ClientId = Id;
            PopulateClientInfo(Customer);
            ResizeForm(this, new EventArgs());
        }
        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");
            }
        }