/*Funcion: actualizar equipos de la receta
          Param: RecipeEquipmentView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeEquipment(RecipeEquipmentView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeEquipmentByRecipeEquipMentIdAndRecipeId(recipe.RecipeId, recipe.RecipeEquipmentId);
            String OldValues = "RecipeId: " + recipe.RecipeId;
            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("RecipeEquipmentId") && row["RecipeEquipmentId"] != DBNull.Value) { OldValues = OldValues + ", RecipeEquipmentId: " + Convert.ToInt32(row["RecipeEquipmentId"]); }

                if (auditDaoResult.Columns.Contains("Link") && row["Link"] != DBNull.Value) { OldValues = OldValues + ", Link: " + (bool)row["Link"]; }

            }

            //Update
            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipeEquipment(recipe);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);
            //Fin update

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe equipment";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEquipmentId: " + recipe.RecipeEquipmentId
                    + ", Link: " + recipe.Link;
                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }
            return logic;
        }
        /*Funcion: actualizar datos receta
          Param: RecipeUpdateValueView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeValue(RecipeUpdateValueView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeParameterByRecipeIdAndParameterId(recipe.RecipeId, recipe.ParameterId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("ParameterId") && row["ParameterId"] != DBNull.Value) { OldValues = OldValues + ", ParameterId: " + Convert.ToInt32(row["ParameterId"]); }
                if (auditDaoResult.Columns.Contains("ParameterValue") && row["ParameterValue"] != DBNull.Value) { OldValues = OldValues + ", ParameterValue: " + Convert.ToInt32(row["ParameterValue"]); }

            }

            //Update
            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipeValue(recipe);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);
            //Fin update

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe parameter value";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", ParameterId: " + recipe.ParameterId
                    + ", ParameterValue: " + recipe.ParameterValue;

                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }
            return logic;
        }
 /*Funcion: Buscar recetas por operacion
   Param: operation
   Return: Lista RecipeView
   */
 public List<RecipeView> searchRecipeByOperation(int operation)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.searchRecipeByOperation(operation);
     return buildRecipe(DaoResult);
 }
        /*Funcion: actualizar una receta
          Param: recipeId,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipe(RecipeUpdateView recipe, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeOldValues(recipe.RecipeId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("RecipeStatus") && row["RecipeStatus"] != DBNull.Value) { OldValues = OldValues + ", RecipeEnable: " + (bool)row["RecipeStatus"]; }
            }

            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipe(recipe);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEnable: " + recipe.RecipeEnable
                    ;
                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }

            return logic;
        }
        /*Funcion: Insertar un parametro para la receta
          Param: RecipeParameterInsertView,AuditDataFromWeb
          Return: Status
          */
        public CUDView InsertRecipeParameter(RecipeParameterInsertView parameter, AuditDataFromWeb audit)
        {
            RecipeDao Dao = new RecipeDao();
            String state = Dao.InsertRecipeParameter(parameter);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert recipe parameter";

                String NewValues = "RecipeId: " + parameter.RecipeId
                    + ", ParameterId: " + parameter.ParameterId
                    + ", ParameterValue: " + parameter.ParameterValue;

                auditservice.formInsert(Action, NewValues, audit);
            }

            return logic;
        }
 /*Funcion: Buscar lista de recetas por parametro de recetas
   Param: datos de busqueda
   Return: Lista RecipeView
   */
 public List<RecipeView> searchRecipe(string partial)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.searchRecipe(partial);
     return buildRecipe(DaoResult);
 }
        /*Funcion: insertar una receta
          Param: RecipeInsertView,AuditDataFromWeb
          Return: Lista RecipeParameterView
          */
        public CUDView insertRecipe(RecipeInsertView recipe, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            RecipeDao Dao = new RecipeDao();

            int operationProcessID = 0;
            DataTable DaoResultIsTest = Dao.isTest(recipe.OperationId);

            foreach (DataRow row in DaoResultIsTest.Rows)
            {
                if (DaoResultIsTest.Columns.Contains("OperationProcessId") && row["OperationProcessId"] != DBNull.Value) { operationProcessID = Convert.ToInt32(row["OperationProcessId"]); }
            }

            if (operationProcessID == 0)
            {
                int countRecipeTest = 0;
                DataTable DaoResultCountRecipeTest = Dao.hasRecipeTest();

                foreach (DataRow row in DaoResultCountRecipeTest.Rows)
                {
                    if (DaoResultCountRecipeTest.Columns.Contains("RecipeTest") && row["RecipeTest"] != DBNull.Value) { countRecipeTest = Convert.ToInt32(row["RecipeTest"]); }
                }

                if (countRecipeTest > 0)
                {
                    logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", "There is already a recipe with 'test' operation.");
                }
                else
                {
                    List<String> state = Dao.insertRecipe(recipe);
                    logic = CUDVerifyLogic.verifierInsertPKReturnMSQL("insert", state);
                }
            }
            else
            {
                List<String> state = Dao.insertRecipe(recipe);
                logic = CUDVerifyLogic.verifierInsertPKReturnMSQL("insert", state);

            }
            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new recipe";

                String NewValues = "RecipeId: " + logic.insertPK
                    + ", RecipeEnable: " + recipe.RecipeEnable
                    + ", OperationId: " + recipe.OperationId
                    + ", ProcessId: " + recipe.ProcessId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: obtiene todos los productos
          Param:
          Return: Lista ProductsView
          */
        public List<ProductsView> getProducts()
        {
            RecipeDao Dao = new RecipeDao();
            DataTable DaoResult = Dao.getProducts();
            List<ProductsView> ViewList = new List<ProductsView>();

            foreach (DataRow row in DaoResult.Rows)
            {
                ProductsView x = new ProductsView();
                if (DaoResult.Columns.Contains("Product") && row["Product"] != DBNull.Value) { x.Product = row["Product"].ToString(); }
                if (DaoResult.Columns.Contains("ProductLineId") && row["ProductLineId"] != DBNull.Value) { x.ProductLineId = Convert.ToInt32(row["ProductLineId"]); }

                ViewList.Add(x);
            }
            return ViewList;
        }
 /*Funcion: Obtener los parametros de una receta
   Param: idRecipe
   Return: Lista RecipeParameterView
   */
 public List<RecipeParameterView> getRecipeParameterData(int idRecipe)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.getRecipeParameterData(idRecipe);
     return buildParameter(DaoResult);
 }
Example #10
0
        /*Funcion: Obtiene los process de una receta por un producto
          Param: idProcess
          Return: Lista RecipeProcessView
          */
        public List<RecipeProcessView> getRecipeProcessForProduct(int idProducts)
        {
            RecipeDao Dao = new RecipeDao();
            DataTable DaoResult = Dao.getRecipeProcessForProduct(idProducts);
            List<RecipeProcessView> ViewList = new List<RecipeProcessView>();

            foreach (DataRow row in DaoResult.Rows)
            {
                RecipeProcessView x = new RecipeProcessView();
                if (DaoResult.Columns.Contains("ProcessName") && row["ProcessName"] != DBNull.Value) { x.ProcessName = row["ProcessName"].ToString(); }
                if (DaoResult.Columns.Contains("ProcessId") && row["ProcessId"] != DBNull.Value) { x.ProcessId = Convert.ToInt32(row["ProcessId"]); }

                ViewList.Add(x);
            }
            return ViewList;
        }
Example #11
0
 /*Funcion: Obtiene los operaciones de una receta por un procesos
   Param: idProcess
   Return: Lista RecipeOperationView
   */
 public List<RecipeOperationView> getRecipeOperationForProcess(int idProcess)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.getRecipeOperationForProcess(idProcess);
     List<RecipeOperationView> ViewList = new List<RecipeOperationView>();
     IndexLogic index = new IndexLogic();
     foreach (DataRow row in DaoResult.Rows)
     {
         RecipeOperationView x = new RecipeOperationView();
         if (DaoResult.Columns.Contains("OperationName") && row["OperationName"] != DBNull.Value) { x.OperationName = row["OperationName"].ToString(); }
         if (DaoResult.Columns.Contains("OperationId") && row["OperationId"] != DBNull.Value) { x.OperationId = Convert.ToInt32(row["OperationId"]); }
         x.Order = index.getIndex();
         ViewList.Add(x);
     }
     return ViewList;
 }
Example #12
0
 /*Funcion: Obtener los parametros de una receta
   Param: idRecipe
   Return: Lista RecipeParameterView
   */
 public List<RecipeEquipmentView> getRecipeEquipmentData(int idRecipe)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.getRecipeEquipmentData(idRecipe);
     return buildEquipment(DaoResult);
 }
Example #13
0
 /*Funcion: obtener los datos de la receta
   Param:
   Return: Lista RecipeView
   */
 public List<RecipeView> getRecipeData()
 {
     RecipeDao Dao = new RecipeDao();
     DataTable recipeDaoResult = Dao.getRecipeData();
     return buildRecipe(recipeDaoResult);
 }
Example #14
0
 /*Funcion: borrar una receta
   Param: recipeId
   Return: status
   */
 public CUDView deleteRecipe(int Id)
 {
     RecipeDao Dao = new RecipeDao();
     String state = Dao.deleteRecipe(Id);
     return CUDVerifyLogic.verifierInsertDeleteUpdate("delete", state);
 }
Example #15
0
        /*Funcion: Insertar el equipo para una receta
          Param: RecipeEquipmentInsertView, AuditDataFromWeb
          Return: Status
          */
        public CUDView insertRecipeEquipment(RecipeEquipmentInsertView recipeEquipmentInsertView, AuditDataFromWeb audit)
        {
            RecipeDao Dao = new RecipeDao();
            String state = Dao.insertRecipeEquipment(recipeEquipmentInsertView);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert recipe equipment";

                String NewValues = "RecipeId: " + recipeEquipmentInsertView.RecipeId
                    + ", EquipmentId: " + recipeEquipmentInsertView.EquipmentId
                    + ", OperationId: " + recipeEquipmentInsertView.OperationId
                    + ", Link: " + recipeEquipmentInsertView.Link;

                auditservice.formInsert(Action, NewValues, audit);
            }

            return logic;
        }
Example #16
0
 /*Funcion: Obtiene los equipos de una receta
   Param: idOperation
   Return: Lista RecipeEquipmentView
   */
 public List<RecipeEquipmentView> getEquipmentByOperation(int idOperation)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.getEquipmentByOperation(idOperation);
     return buildEquipment(DaoResult);
 }
Example #17
0
 /*Funcion: Obtiene los parametros de una receta por un proceso
   Param: idProcess
   Return: Lista RecipeParameterView
   */
 public List<RecipeParameterView> getParameterByProcess(int idProcess)
 {
     RecipeDao Dao = new RecipeDao();
     DataTable DaoResult = Dao.getParameterByProcess(idProcess);
     return buildParameter(DaoResult);
 }