/*
        Metodo que se utiliza para realizar una actualizacion
        */
        private void updateAuxiliar()
        {
            //Se verifica que se haya seleccionado un equipo
            if (HttpContext.Current.Session["EquipmentId"] != null)
            {
                //Se verifica que se hayan completado los espacios HMI, PLC y Location
                if (HMIAddressText.Text != "" & PLCAddressText.Text != "" & LocationText.Text != "")
                {
                    //Se obtienen los datos
                    EquipmentService equipmentService = new EquipmentService();
                    EquipmentUpdateView equipment = new EquipmentUpdateView();
                    equipment.HMIAddress = HMIAddressText.Text;
                    equipment.Location = LocationText.Text;
                    equipment.PLCAddress = PLCAddressText.Text;
                    equipment.PLCLink = ethernetLink.Items[0].Selected;
                    equipment.Status = EquipmentEnable.Items[0].Selected;
                    equipment.Id = EquipmentIdText.Text;
                    //Se muestra la ventana de justificacion para la actualizacion
                    String reason = Session["reason"].ToString();
                    String user = Context.User.Identity.Name;
                    //Se llenan los datos para la auditoria
                    AuditDataFromWeb audit = new AuditDataFromWeb();
                    audit.Reason = reason;
                    audit.StationIP = General.getIp(this.Page);
                    audit.UserName = user;
                    //Se realiza la actualizacion
                    CUDView crud = equipmentService.updateEquipment(equipment, audit);

                    if (crud.update == false)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Equipment')", true);
                    }

                    clearFields1();
                    fillEquipmentTable();

                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
                }
            }
        }
Пример #2
0
 /*
   Funcion: Actualiza un  equipo
   Param: Id, GroupId,BrandId,Model,HMIAddress,PLCLink,PLCAddress,Location,Status
   Return: Status
   */
 public String updateEquipment(EquipmentUpdateView equipment)
 {
     return context.InsertUpdateDeleteMSQL("EXEC updateEquipment @EquipmentId='" + equipment.Id + "', @EquipmentHMIAddress='" + equipment.HMIAddress + "', @EquipmentPLCLink="+
         equipment.PLCLink + ", @EquipmentPLCAddress='" + equipment.PLCAddress + "', @EquipmentLocation='" + equipment.Location + "', @EquipmentStatus=" + equipment.Status + ";");
 }
        private void updateAuxiliar()
        {
            if (HttpContext.Current.Session["EquipmentId"] != null)
            {
                if (HMIAddressText.Text != "" & PLCAddressText.Text != "" & LocationText.Text != "")
                {
                    string confirmValue = Request.Form["confirm_value"];
                    if (confirmValue == "Yes")
                    {
                        EquipmentService equipmentService = new EquipmentService();
                        EquipmentUpdateView equipment = new EquipmentUpdateView();

                        equipment.HMIAddress = HMIAddressText.Text;
                        equipment.Location = LocationText.Text;
                        equipment.PLCAddress = PLCAddressText.Text;
                        equipment.PLCLink = ethernetLink.Items[0].Selected;
                        equipment.Status = EquipmentEnable.Items[0].Selected;
                        equipment.Id = EquipmentIdText.Text;

                        CUDView crud = equipmentService.updateEquipment(equipment);

                        if (crud.update == false)
                        {
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Equipment')", true);
                        }

                        clearFields1();
                        fillEquipmentTable();
                    }
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true);
                }
            }
        }
Пример #4
0
        /*Funcion: actualizar equipos
          Param: EquipmentUpdateView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateEquipment(EquipmentUpdateView equipment, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getEquipmentOldValues(equipment.Id);
            String OldValues = "EquipmentId: " + equipment.Id;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("HMI") && row["HMI"] != DBNull.Value) { OldValues = OldValues + ", HMIAddress: " + row["HMI"].ToString(); }
                if (auditDaoResult.Columns.Contains("Location") && row["Location"] != DBNull.Value) { OldValues = OldValues + ", Location: " + row["Location"].ToString(); }
                if (auditDaoResult.Columns.Contains("PLC") && row["PLC"] != DBNull.Value) { OldValues = OldValues + ", PLCAddress: " + row["PLC"].ToString(); }
                if (auditDaoResult.Columns.Contains("PLCLink") && row["PLCLink"] != DBNull.Value) { OldValues = OldValues + ", PLCLink: " + row["PLCLink"].ToString(); }
                if (auditDaoResult.Columns.Contains("Enabled") && row["Enabled"] != DBNull.Value) { OldValues = OldValues + ", Status: " + row["Enabled"].ToString(); }
            }

            EquipmentDao Dao = new EquipmentDao();
            String state = Dao.updateEquipment(equipment);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update Equipment";
                String newValues = "EquipmentId: " + equipment.Id;
                newValues = newValues + ", HMIAddress: " + equipment.HMIAddress;
                newValues = newValues + ", Location: " + equipment.Location;
                newValues = newValues + ", PLCAddress: " + equipment.PLCAddress;
                newValues = newValues + ", PLCLink: " + equipment.PLCLink;
                newValues = newValues + ", Status: " + equipment.Status;

                auditservice.formUpdate(Action, newValues, OldValues, audit);
            }

            return logic;
        }