Example #1
0
 /// <summary>
 /// Create a new Specification object.
 /// </summary>
 /// <param name="specID">Initial value of the SpecID property.</param>
 /// <param name="machineID">Initial value of the MachineID property.</param>
 /// <param name="specUrl">Initial value of the SpecUrl property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="machineSpecID">Initial value of the MachineSpecID property.</param>
 public static Specification CreateSpecification(global::System.Int32 specID, global::System.Int32 machineID, global::System.String specUrl, global::System.String status, global::System.Int32 machineSpecID)
 {
     Specification specification = new Specification();
     specification.SpecID = specID;
     specification.MachineID = machineID;
     specification.SpecUrl = specUrl;
     specification.Status = status;
     specification.MachineSpecID = machineSpecID;
     return specification;
 }
Example #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Specifications EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSpecifications(Specification specification)
 {
     base.AddObject("Specifications", specification);
 }
        protected void btnUploadSpec_Click(object sender, EventArgs e)
        {
            if (uploadFile.HasFile == false)
            {
                UploadDetails.Text = "Please first select a file to upload...";
            }
            else
            {
                using (GESEntities db = new GESEntities())
                {
                    int iMachineID = Int32.Parse(lblMachineID.Text.Substring(lblMachineID.Text.IndexOf(":") + 1).Trim());

                    //Fetch next photo # in the photo table for this machine
                    int iNextSpecID = 0;

                    System.Nullable<Int32> GetNextSpec = (from p in db.Specifications where p.MachineID == iMachineID select (int?)p.MachineSpecID).Max();

                    if (GetNextSpec.HasValue)
                    {
                        iNextSpecID = GetNextSpec.Value + 1;
                    }
                    else
                    {
                        iNextSpecID = 1;
                    }

                    //Save the image
                    string fileName = iMachineID.ToString() + "-" + iNextSpecID.ToString() + Path.GetExtension(uploadFile.FileName);
                    string filePath = Server.MapPath("~/Specs/" + fileName);

                    string fileNameTemp = "Temp" + iMachineID.ToString() + "-" + iNextSpecID.ToString() + Path.GetExtension(uploadFile.FileName);
                    string filePathTemp = Server.MapPath("~/Specs/" + fileNameTemp);
                    uploadFile.SaveAs(filePathTemp);

                    //delete Temp file
                    if (File.Exists(filePathTemp))
                    {
                        File.Delete(filePathTemp);
                    }

                    // Display the uploaded file's details
                    UploadDetails.Text = string.Format(@"Uploaded file: {0}<br /> File size (in bytes): {1:N0}<br /> Content-type: {2}", uploadFile.FileName, uploadFile.FileBytes.Length, uploadFile.PostedFile.ContentType);

                    //insert a row into the photos table
                    Specification newSpec = new Specification();
                    newSpec.MachineID = iMachineID;
                    newSpec.SpecName = "Test";
                    newSpec.SpecDescription = "Test";
                    newSpec.SpecUrl = "Specs/" + fileName;
                    newSpec.Status = "Active";
                    newSpec.MachineSpecID = iNextSpecID;

                    db.Specifications.AddObject(newSpec);
                    db.SaveChanges();

                    //Refresh thumbnail list
                    SpecsEntityDataSource.WhereParameters.Clear();
                    SpecsEntityDataSource.AutoGenerateWhereClause = true;
                    SpecsEntityDataSource.WhereParameters.Add("MachineID", TypeCode.Int32, iMachineID.ToString());

                    gridSpecs.Visible = true;
                }
            }
        }