Ejemplo n.º 1
0
        private void BindGridViewWorkers()
        {
            WorkerBusinessLogic WorkerBusinessLogic = new WorkerBusinessLogic();

            gridViewWorkers.DataSource = WorkerBusinessLogic.GetAll();
            gridViewWorkers.DataBind();
        }
Ejemplo n.º 2
0
        public void btnAddNewAtivityWorker_Click(object sender, EventArgs e)
        {
            System.Text.StringBuilder sb = null;

            double hoursWorked;

            if (!Double.TryParse(txtAddHours.Text.Replace('.', ','), out hoursWorked) || hoursWorked <= 0)
            {
                this.lblAddErrorMessage.Text = "Valor das horas não é válido!";
                return;
            }


            if (string.IsNullOrWhiteSpace(txtAddComment.Text))
            {
                this.lblAddErrorMessage.Text = "É necessário informar um comentário!";
                return;
            }


            int workerID = Convert.ToInt32(hfNewActivityWorker.Value);

            Activity activity = CurrentActivity();

            WorkerBusinessLogic workerBusinessLogic = new WorkerBusinessLogic();
            Worker worker = workerBusinessLogic.GetByID(workerID);

            ActivityBusinessLogic activityBusinessLogic = new ActivityBusinessLogic();

            double hoursAvaiable = activityBusinessLogic.GetAvaiablesHoursByWorkerOnDate(worker, activity.Date);

            if (hoursWorked > hoursAvaiable)
            {
                this.lblAddErrorMessage.Text = "As horas trabalhas superam as horas dispónives!";
                return;
            }



            activityBusinessLogic.AttachWoker(activity, worker, hoursWorked, txtAddComment.Text);



            ScriptManager.RegisterClientScriptBlock(this,
                                                    this.GetType(),
                                                    "EditHideModalScript",
                                                    Util.GetScriptToHideModalDialog("addModal"),
                                                    false);

            BindDdListWorkers();
            BindGridVeiwWorksByActivity();
        }
Ejemplo n.º 3
0
        protected void btnAddNewWorker_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtNewWorkerName.Text))
            {
                this.lblNewWorkerMessage.Text = "O nome deve ser preenchido!";
                return;
            }


            if (string.IsNullOrWhiteSpace(this.txtNewWorkerLastName.Text))
            {
                this.lblNewWorkerMessage.Text = "o Sobrenome deve ser preenchido!";
                return;
            }



            WorkerBusinessLogic workerBusinessLogic = new WorkerBusinessLogic();
            Worker Worker = new Worker();


            Worker.Name     = txtNewWorkerName.Text;
            Worker.LastName = txtNewWorkerLastName.Text;

            IResultOperation result = workerBusinessLogic.InsertWithRule(Worker);

            if (result.Status != ResultOperationStatus.OK)
            {
                lblNewWorkerMessage.Text = result.Message;
                return;
            }

            BindGridViewWorkers();



            ScriptManager.RegisterClientScriptBlock(this,
                                                    this.GetType(),
                                                    "AddHideModalScript",
                                                    Util.GetScriptToHideModalDialog("addModal"),
                                                    false);


            this.txtNewWorkerName.Text     = string.Empty;
            this.txtNewWorkerLastName.Text = string.Empty;
            this.lblNewWorkerMessage.Text  = string.Empty;
        }
Ejemplo n.º 4
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            WorkerBusinessLogic WorkerBusinessLogic = new WorkerBusinessLogic();
            Worker Worker = WorkerBusinessLogic.GetByID(Convert.ToInt32(HfDeleteID.Value));

            WorkerBusinessLogic.Delete(Worker);


            ScriptManager.RegisterClientScriptBlock(this,
                                                    this.GetType(),
                                                    "delHideModalScript",
                                                    Util.GetScriptToHideModalDialog("deleteModal"),
                                                    false);


            BindGridViewWorkers();
        }
Ejemplo n.º 5
0
        protected void btnUpdateWorker_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtEditWorkerName.Text))
            {
                lblEditWorkerMessage.Text = "O nome deve ser preenchido!";
                return;
            }


            if (string.IsNullOrWhiteSpace(this.txtEditWorkerLastName.Text))
            {
                lblEditWorkerMessage.Text = "o Sobrenome deve ser preenchido!";
                return;
            }



            WorkerBusinessLogic workerBusinessLogic = new WorkerBusinessLogic();
            Worker worker = workerBusinessLogic.GetByID(Convert.ToInt32(HfUpdateID.Value));

            string currentName = worker.Name;

            worker.Name     = txtEditWorkerName.Text;
            worker.LastName = txtEditWorkerLastName.Text;

            IResultOperation result = workerBusinessLogic.UpdatetWithRule(worker);

            if (result.Status != ResultOperationStatus.OK)
            {
                lblEditWorkerMessage.Text = result.Message;
                worker.Name = currentName;
                return;
            }


            BindGridViewWorkers();


            ScriptManager.RegisterClientScriptBlock(this,
                                                    this.GetType(),
                                                    "EditHideModalScript",
                                                    Util.GetScriptToHideModalDialog("editModal"),
                                                    false);

            lblEditWorkerMessage.Text = string.Empty;
        }
Ejemplo n.º 6
0
        protected void btnAddActivityWorker_Click(object sender, EventArgs e)
        {
            if (lBoxWorkers.SelectedIndex <= -1)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("alert('É necessário selecionar um Colaborador')");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertSelectWorker", sb.ToString(), false);
                return;
            }



            int      workerID = Convert.ToInt32(lBoxWorkers.SelectedValue);
            Activity activity = CurrentActivity();

            WorkerBusinessLogic workerBusinessLogic = new WorkerBusinessLogic();
            Worker worker = workerBusinessLogic.GetByID(workerID);

            hfNewActivityWorker.Value = workerID.ToString();

            ActivityBusinessLogic activityBusinessLogic = new ActivityBusinessLogic();

            double hoursAvaiable = activityBusinessLogic.GetAvaiablesHoursByWorkerOnDate(worker, activity.Date);


            this.txtAddDate.Text          = activity.Date.ToShortDateString();
            this.txtAddWorkername.Text    = worker.FullName;
            this.lblAddAvaiableHours.Text = hoursAvaiable.ToString();

            this.txtAddHours.Text   = "0";
            this.txtAddComment.Text = string.Empty;


            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(),
                "AddShowModalScript",
                Util.GetScriptToShowModalDialog("addModal"),
                false);


            BindDdListWorkers();
        }
Ejemplo n.º 7
0
        protected void BindDdListWorkers()
        {
            IList <Worker> listWorker = new List <Worker>();


            WorkerBusinessLogic workerBusinessLogic = new WorkerBusinessLogic();
            IList <Worker>      listAllWorker       = workerBusinessLogic.GetAll();

            IList <Worker> listActivityWorkers = CurrentActivity().GetWorkers();

            foreach (var worker in listAllWorker)
            {
                if (!listActivityWorkers.Contains(worker))
                {
                    listWorker.Add(worker);
                }
            }

            this.lBoxWorkers.DataSource = listWorker;
            this.lBoxWorkers.DataBind();
        }
Ejemplo n.º 8
0
 public WorkerController(WorkerBusinessLogic logic)
 {
     _logic = logic;
 }