Ejemplo n.º 1
0
        protected void _Login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            users    auxUser = new users();
            usersBus oUser   = new usersBus();

            auxUser = oUser.usersGetByUserName(_Login.UserName);

            string hashPwd = Services.Utility.ResumeSHA1(_Login.Password);

            if (auxUser != null)
            {
                if (String.Compare(hashPwd, auxUser.UserPassword) == 0)
                {
                    FormsAuthentication.RedirectFromLoginPage(_Login.UserName, _Login.RememberMeSet);
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();

            culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
            culture.DateTimeFormat.LongTimePattern  = "";
            Thread.CurrentThread.CurrentCulture     = culture;

            taskdetails    auxNewTaskDetail = new taskdetails();
            taskdetailsBus oTaskDetail      = new taskdetailsBus();

            tasks    auxTasks = new tasks();
            tasksBus oTasks   = new tasksBus();

            users    auxUser = new users();
            usersBus oUser   = new usersBus();

            eventsdetectionBus oEventsDetection = new eventsdetectionBus();

            bool needRequiredFields = false;
            int  saveType           = 0;

            if (btnNew.Enabled)
            {
                saveType = 2;
            }
            if (!btnNew.Enabled)
            {
                saveType = 1;
            }

            if (String.IsNullOrEmpty(txtDateTime.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtEffortHours.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtDetail.Text))
            {
                needRequiredFields = true;
            }
            if (String.IsNullOrEmpty(txtTaskId.Text))
            {
                needRequiredFields = true;
            }

            if (!needRequiredFields)
            {
                auxUser = oUser.usersGetByUserName(HttpContext.Current.User.Identity.Name);

                DateTime dateTime = DateTime.ParseExact(txtDateTime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                auxNewTaskDetail.DateTime    = dateTime;
                auxNewTaskDetail.EffortHours = Convert.ToDecimal(txtEffortHours.Text);
                auxNewTaskDetail.Details     = txtDetail.Text;
                auxNewTaskDetail.TaskId      = Convert.ToInt32(txtTaskId.Text);
                auxNewTaskDetail.UserId      = Convert.ToInt32(ddlUsers.SelectedValue);
                int auxTaskStatus   = Convert.ToInt32(ddlTaskStatus.SelectedValue);
                int auxUserAssigned = Convert.ToInt32(ddlUsers.SelectedValue);
                switch (saveType)
                {
                case 1:     //save
                    if (oTaskDetail.taskdetailsAdd(auxNewTaskDetail) > 0)
                    {
                        if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n";
                        }

                        auxTasks = oTasks.tasksGetById(Convert.ToInt32(txtTaskId.Text));

                        if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n";
                        }

                        if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n";
                        }

                        clearFields();
                        activateFields(false, true);
                        btnNew.Enabled = true;
                        getTaskDetailsData(TaskId);
                        lblMessage.Text = "Datos guardados correctamente!";
                    }
                    else
                    {
                        lblMessage.Text = "Error al guardar los datos!";
                    }
                    break;

                case 2:     //update

                    if (Convert.ToInt32(hfTaskStatusOrigin.Value) != auxTaskStatus)
                    {
                        if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n";
                        }

                        if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n";
                        }
                    }

                    if (Convert.ToInt32(hfUserOrigin.Value) != auxUserAssigned)
                    {
                        if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned))
                        {
                            lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n";
                        }
                    }

                    auxNewTaskDetail.TaskDetailsId = Convert.ToInt32(txtTaskDetailId.Text);

                    if (oTaskDetail.taskdetailsUpdate(auxNewTaskDetail))
                    {
                        lblMessage.Text = "Datos actualizados correctamente!";
                        clearFields();
                        activateFields(false, true);
                        btnSave.Enabled = false;
                        getTaskDetailsData(TaskId);
                        lblMessage.Text = "Datos actualizados correctamente!";
                    }
                    else
                    {
                        lblMessage.Text = "Error al guardar los datos!";
                    }
                    break;
                }
            }
            else
            {
                lblMessage.Text = "Datos requeridos no cargados...";
            }
        }