Exemplo n.º 1
0
 public RequisitionPage(Requisition requisition)
 {
     InitializeComponent();
     this._requisition = requisition;
     try
     {
         // Get requisition's resources
         LoadRequisitionResources();
     }
     catch (SqlException exc)
     {
         Helpers.ShowCustomDialogBox(exc);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     // Set requisition infos
     requisition_id.Text      = _requisition.RequisitionID.ToString();
     content_list.ItemsSource = _requisition.Resources;
     requisition_user.Text    = _requisition.User.FullName;
     requisition_project.Text = _requisition.ReqProject.ProjectName;
     requisition_date.Text    = _requisition.ReqDate.ToShortDateString();
 }
        public void goToRequisitionPage(Requisition req)
        {
            RequisitionPage page = new RequisitionPage(req);

            frame.Navigate(page);
        }
Exemplo n.º 3
0
        private void loadRequisitions()
        {
            cn = Helpers.getSGBDConnection();
            if (!Helpers.verifySGBDConnection(cn))
            {
                return;
            }

            SqlCommand cmd = new SqlCommand("SELECT * FROM DML.LAST_EQUIP_REQUISITIONS (@ProductName, @Model, @Manufacturer)", cn);

            cmd.Parameters.Clear();
            cmd.Parameters.AddWithValue("@ProductName", _equipment.ProductName);
            cmd.Parameters.AddWithValue("@Model", _equipment.Model);
            cmd.Parameters.AddWithValue("@Manufacturer", _equipment.Manufactor);
            SqlDataReader reader   = cmd.ExecuteReader();
            CultureInfo   provider = CultureInfo.InvariantCulture;

            while (reader.Read())
            {
                try
                {
                    Requisition r = new Requisition(
                        int.Parse(reader["RequisitionID"].ToString()),
                        new Project(
                            int.Parse(reader["ProjectID"].ToString()),
                            reader["PrjName"].ToString(),
                            reader["PrjDescription"].ToString()),
                        null,
                        DateTime.ParseExact(reader["ReqDate"].ToString(), "yyMMddHHmm", provider)
                        );
                    r.addResource(new ElectronicUnit(
                                      int.Parse(reader["ResourceID"].ToString()),
                                      new ElectronicResources(
                                          reader["ProductName"].ToString(),
                                          reader["Manufactor"].ToString(),
                                          reader["Model"].ToString(),
                                          reader["Description"].ToString(),
                                          null,
                                          reader["PathToImage"].ToString()),
                                      reader["Supplier"].ToString()
                                      ));
                    RequisitionsData.Add(r);
                }
                catch (Exception e)
                {
                    foreach (Requisition r in RequisitionsData)
                    {
                        if (r.RequisitionID == int.Parse(reader["RequisitionID"].ToString()))
                        {
                            r.addResource(new ElectronicUnit(
                                              int.Parse(reader["ResourceID"].ToString()),
                                              new ElectronicResources(
                                                  reader["ProductName"].ToString(),
                                                  reader["Manufactor"].ToString(),
                                                  reader["Model"].ToString(),
                                                  reader["Description"].ToString(),
                                                  null,
                                                  reader["PathToImage"].ToString()),
                                              reader["Supplier"].ToString()
                                              ));
                        }
                    }
                }
            }
            cn.Close();
        }