Exemplo n.º 1
0
    public ActionResult Create(Models.MSTR_BlackBox BlackBoxData) {
      if (!exLogic.User.hasAccess("BLACKBOX.CREATE"))
        return RedirectToAction("NoAccess", "Home");
      if (ModelState.IsValid) {
        BlackBox BB = new BlackBox();
        //  BlackBox.BlackBoxID = 0;
        BlackBoxData.IsActive = 1;
        BlackBoxData.CurrentStatus = "IN";
        BlackBoxData.LastReceiveId = 0;
        BlackBoxData.LastRentalId = 0;
        BlackBoxData.CreatedBy = Util.getLoginUserID();
        BlackBoxData.CreatedOn = DateTime.Now;
        BlackBoxData.LastUpdateDate = DateTime.Now;
        BlackBoxData.BlackBoxCode = BB.getSerialNumber(BlackBoxData.BlackBoxSerial).ToString();
        db.MSTR_BlackBox.Add(BlackBoxData);

        db.SaveChanges();

        db.Dispose();

        return RedirectToAction("BlackBoxList", "BlackBox");
      } else {
        ViewBag.Title = "Create BlackBox";
        return View(BlackBoxData);
      }
    }
Exemplo n.º 2
0
        public ActionResult Create(MSTR_Pilot_Log PilotLog)
        {
            if (!exLogic.User.hasAccess("PILOTLOG.CREATE"))
            {
                return(RedirectToAction("NoAccess", "Home"));
            }
            if (PilotLog.DroneId < 1 || PilotLog.DroneId == null)
            {
                ModelState.AddModelError("DroneID", "You must select a UAS.");
            }


            if (ModelState.IsValid)
            {
                ExponentPortalEntities db = new ExponentPortalEntities();
                db.MSTR_Pilot_Log.Add(PilotLog);
                db.SaveChanges();

                db.Dispose();
                return(RedirectToAction("UserDetail", "User", new { ID = PilotLog.PilotId }));
            }
            else
            {
                ViewBag.Title = "Create Drone Flight";
                return(View(PilotLog));
            }
        }
Exemplo n.º 3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Exemplo n.º 4
0
    public ActionResult Create(DroneFlight theFlight) {
      if (!exLogic.User.hasAccess("FLIGHT.CREATE"))
        return RedirectToAction("NoAccess", "Home");
      if (theFlight.DroneID < 1 || theFlight.DroneID == null)
        ModelState.AddModelError("DroneID", "You must select a Drone.");
      if (theFlight.PilotID < 1 || theFlight.PilotID == null)
        ModelState.AddModelError("PilotID", "Pilot is required for a Flight.");
      if (theFlight.GSCID < 1 || theFlight.GSCID == null)
        ModelState.AddModelError("GSCID", "A Ground Station Controller should be slected.");

      //if (Request != null)
      //{
      //    var a = Request["fileinputError"];
      //    HttpPostedFileBase file = Request.Files["fileinput"];
      //    if(file==null) ModelState.AddModelError("fileinput", "You must select a Document.");
      //}

      if (ModelState.IsValid) {
        int ID = 0;
        ExponentPortalEntities db = new ExponentPortalEntities();
        db.DroneFlight.Add(theFlight);
        db.SaveChanges();
        ID = theFlight.ID;
        db.Dispose();

        //Move the uploaded file to correct path
        if (Request["FileName"] != null)
          MoveUploadFileTo((int)theFlight.DroneID, theFlight.ID);

        //insert into log table
        string sql = "insert into MSTR_Pilot_Log(DroneId,Date,PilotId,MultiDashRotor,FlightID)values(" + theFlight.DroneID + ",'" + System.DateTime.Now.ToString("MM/dd/yyyy") + "'," + theFlight.PilotID + "," + (theFlight.FlightHours == null ? 0 : (theFlight.FlightHours / 60)) + "," + ID + ")";
        Util.doSQL(sql);

        return RedirectToAction("Detail", new { ID = ID });
      } else {
        ViewBag.Title = "Create RPAS Flight";
        return View(theFlight);
      }

    }
Exemplo n.º 5
0
        public ActionResult Create(MSTR_Parts Parts)
        {
            try
            {
                if (!exLogic.User.hasAccess("PARTS.CREATE"))
                {
                    return(RedirectToAction("NoAccess", "Home"));
                }
                if (Parts.SupplierId < 1 || Parts.SupplierId == null)
                {
                    ModelState.AddModelError("SupplierId", "You must select a Company");
                }


                if (ModelState.IsValid)
                {
                    Parts.CreatedBy = Util.getLoginUserID();
                    Parts.CreatedOn = DateTime.Now;
                    db.MSTR_Parts.Add(Parts);

                    db.SaveChanges();

                    db.Dispose();

                    return(RedirectToAction("Detail", "Parts", new { ID = Parts.PartsId }));
                }
                else
                {
                    ViewBag.Title = "Create Drone Flight";
                    return(View(Parts));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 6
0
    private void setColumDef() {
      int ColumnCounter = 0;
      String mySQL = SQL;  

      if(isFilterByTop) { 
        string pattern = @"SELECT[\s\n]";
        Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
        
        mySQL = rgx.Replace(SQL, "SELECT TOP 1 ");
      }


      /*
      //can not use the none filter, we need to find is there any rows
      //exists to build the list

      //http://www.codeproject.com/Articles/32524/SQL-Parser

      String NowRowFilter = "1 = 0";
      Parser.SqlParser myParser = new Parser.SqlParser();
      myParser.Parse(SQL);
      if(string.IsNullOrEmpty(myParser.WhereClause)) {
        myParser.WhereClause = NowRowFilter;
      } else {
        myParser.WhereClause += " AND " + NowRowFilter;
      }
      String mySQL = myParser.ToText();
      */

      var cmd = ctx.Database.Connection.CreateCommand();
      DataTable schemaTable;
      ctx.Database.Connection.Open();
      cmd.CommandText = mySQL;

      DbDataReader myReader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
      HasRows = myReader.HasRows;
      schemaTable = myReader.GetSchemaTable();
      /*
      //Retrieve column schema into a DataTable.
      foreach (DataRow myField in schemaTable.Rows) {
        Response.Write("<P>");
        foreach (DataColumn Field in schemaTable.Columns) {
          Response.Write(Field.ColumnName + ": " + myField[Field] + "<br>\n");
        }
        Response.Write("</P>");
      }
      */

      //For each field in the table...
      foreach (DataRow myField in schemaTable.Rows) {
        ColumnCounter++;

        //For each property of the field...
        //Columns.Add(myField["BaseTableName"] + "." + myField["BaseColumnName"]);      
        String ColumnName = myField["ColumnName"].ToString();
        String FieldType = myField["DataType"].ToString();
        if (FieldType == "System.String") {
          FilterColumns.Add(ColumnName);
        }
        if (ColumnCounter == 1 && FieldType == "System.String") {
          _SortOrder = "asc";
        }


        if (myField["IsHidden"].ToString() == "False") {
          switch (ColumnName.ToLower()) {
          case "_totalrecords":
          break;
          case "_pkey":
          IsPrimaryKey = true;
          break;
          default:
          ColumDef.Add(ColumnName);
          break;
          } //switch
        }

      }//foreach

      myReader.Close();
      cmd.Dispose();
      ctx.Dispose();

    }//setColumDef()