private void btnBuscar_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtNome.Text))
            {
                hospital = HospitalDAO.BuscarPorNome(txtNome.Text);
                if (hospital != null)
                {
                    btnCadastrar.IsEnabled = false;
                    btnAlterar.IsEnabled   = true;
                    btnRemover.IsEnabled   = true;

                    txtId.Text              = hospital.Id.ToString();
                    txtCriadoEm.Text        = hospital.CriadoEm.ToString();
                    txtNome.Text            = hospital.Nome;
                    txtEndereco.Text        = hospital.Endereco;
                    txtTelefone.Text        = hospital.Telefone;
                    txtNomeResponsavel.Text = hospital.NomeResponsavel;
                }
                else
                {
                    _messageBoxClass.MensagemErroOK("Funcionario não encontrado!!!");
                    LimparForm();
                }
            }
            else
            {
                _messageBoxClass.MensagemErroOK("Preencha o campo Nome!!!");
            }
        }
 public RetiradaController(RetiradaDAO retiradaDAO, HospitalDAO hospitalDAO, TipoSanguineoDAO tipoSanguineoDAO, EstoqueSangueDAO estoqueSangueDAO)
 {
     _retiradaDAO      = retiradaDAO;
     _hospitalDAO      = hospitalDAO;
     _tipoSanguineoDAO = tipoSanguineoDAO;
     _estoqueSangueDAO = estoqueSangueDAO;
 }
        private void btnCadastrar_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtNome.Text) ||
                !string.IsNullOrEmpty(txtEndereco.Text) ||
                !string.IsNullOrEmpty(txtTelefone.Text) ||
                !string.IsNullOrEmpty(txtNomeResponsavel.Text)
                )
            {
                Hospital hospital = new Hospital();

                hospital.Nome            = txtNome.Text;
                hospital.Endereco        = txtEndereco.Text;
                hospital.Telefone        = txtTelefone.Text;
                hospital.NomeResponsavel = txtNomeResponsavel.Text;


                if (HospitalDAO.Cadastrar(hospital))
                {
                    _messageBoxClass.MensagemInfoOK("Hospital Salvo!");
                    LimparForm();
                }
                else
                {
                    _messageBoxClass.MensagemErroOK("Hospital ja cadastrado!");
                }
            }
            else
            {
                _messageBoxClass.MensagemErroOK("Preencha os campos corretamente!");
            }
        }
示例#4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            txtData.Text = DateTime.Now.ToString();

            cboTipoSanguineo.ItemsSource = TipoSanguineoDAO.Listar();

            cboHospital.ItemsSource       = HospitalDAO.Listar();
            cboHospital.DisplayMemberPath = "Nome";
            cboHospital.SelectedValuePath = "Id";
        }
 private void btnRemover_Click(object sender, RoutedEventArgs e)
 {
     if (hospital != null)
     {
         HospitalDAO.Remover(hospital);
         _messageBoxClass.MensagemInfoOK("Funcionario Removido!");
     }
     else
     {
         _messageBoxClass.MensagemErroOK("O Funcionario não foi removido");
     }
     LimparForm();
 }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IList <Hospital> hospital = HospitalDAO.RetrieveAll().Where(x => !string.IsNullOrWhiteSpace(x.Name) && !x.Name.Equals("SuperAdminHospital")).ToList();
                DropDownHospital.DataSource     = hospital;
                DropDownHospital.DataValueField = "Id";
                DropDownHospital.DataTextField  = "Name";
                DropDownHospital.DataBind();

                DropDownRole.DataSource = Enum.GetNames(typeof(UserRole));
                DropDownRole.DataBind();
            }
        }
        private void btnAlterar_Click(object sender, RoutedEventArgs e)
        {
            if (hospital != null)
            {
                hospital.Nome            = txtNome.Text;
                hospital.Endereco        = txtEndereco.Text;
                hospital.Telefone        = txtTelefone.Text;
                hospital.NomeResponsavel = txtNomeResponsavel.Text;

                HospitalDAO.Alterar(hospital);
                _messageBoxClass.MensagemInfoOK("Funcionario Alterado!");
            }
            else
            {
                _messageBoxClass.MensagemErroOK("O Funcionario não foi alterado");
            }
            LimparForm();
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string               userName    = TextBoxNameUserName.Value;
            string               password    = TextBoxNamePassword.Value;
            Hospital             theHospital = !string.IsNullOrWhiteSpace(DropDownHospital.SelectedValue) ? new HospitalDAO().Retrieve(Convert.ToInt64(DropDownHospital.SelectedValue)) : null;
            IList <HospitalUser> user        = theHospital != null ? new HospitalUserDAO().RetrieveByLoginDetails(theHospital, userName, password) : null;

            if (user != null)
            {
                TheHospital = user.FirstOrDefault().TheHospital;
            }
            else
            {
                TheHospital = null;
            }
            if (!IsPostBack)
            {
                IList <Hospital> hospital = HospitalDAO.RetrieveAll();
                DropDownHospital.DataSource     = hospital;
                DropDownHospital.DataValueField = "Id";
                DropDownHospital.DataTextField  = "Name";
                DropDownHospital.DataBind();
            }
        }
示例#9
0
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            //var userDB = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameFName.Value))
                {
                    throw new Exception("First Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameLName.Value))
                {
                    throw new Exception("Last Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameEmail.Value))
                {
                    throw new Exception("Email field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameUName.Value))
                {
                    throw new Exception("User Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNamePhone.Value))
                {
                    throw new Exception("Phone No. field is required");
                }
                if (!string.IsNullOrWhiteSpace(DropDownRole.SelectedItem.Text) && !DropDownRole.SelectedItem.Text.Equals("SuperAdmin"))
                {
                    throw new Exception("SuperAdmin user role must be selected here");
                }
                string userName = TextBoxNameUName.Value.Trim();
                string superAdminHospitalName        = "SuperAdminHospital";
                IList <HospitalUser> adminUserList   = new HospitalUserDAO().RetrieveAdminUser(userName);
                IList <Hospital>     theHospitalList = new HospitalDAO().RetrieveByName(superAdminHospitalName);

                if (adminUserList.Count == 0)
                {
                    //create headquarters branch for user
                    Hospital hospital = new Hospital();
                    if (theHospitalList == null && theHospitalList.Count <= 0)
                    {
                        hospital.Name                 = "SuperAdminHospital";
                        hospital.Address              = "Mars";
                        hospital.PrimaryContactEmail  = "NONE";
                        hospital.PrimaryContactNumber = "NONE";
                        HospitalDAO.Save(hospital);
                    }

                    //User user =Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();
                    HospitalUser user = new HospitalUser();
                    user.FirstName   = TextBoxNameFName.Value;
                    user.LastName    = TextBoxNameLName.Value;
                    user.OtherNames  = TextBoxNameONames.Value;
                    user.Email       = TextBoxNameEmail.Value;
                    user.UserName    = TextBoxNameUName.Value;
                    user.Phone       = TextBoxNamePhone.Value;
                    user.UserRole    = (UserRole)Enum.Parse(typeof(UserRole), DropDownRole.SelectedValue);
                    user.TheHospital = (theHospitalList == null && theHospitalList.Count <= 0) ? hospital : theHospitalList.First();
                    //user.Branch.Id = branch.Id;
                    //user.Branch.BranchName = branch.BranchName;

                    HospitalUserLogic userLogic = new HospitalUserLogic();
                    user.Password     = userLogic.HashPassword(userLogic.CreatePassword());
                    user.IsFirstLogin = true;       //update this field to false once user changes password successfully

                    user.DateCreated = DateTime.Now;
                    HospitalDAO.Save(hospital);
                    userLogic.SendMail(user.Email, user.Password);
                    HospitalUserDAO.Save(user);
                    //Response.Redirect("../Start/Login.aspx");
                }

                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "UserName Already Exists!" + "', function(){});</script>", false);
                }


                TextBoxNameFName.Value  = String.Empty;
                TextBoxNameLName.Value  = String.Empty;
                TextBoxNameONames.Value = String.Empty;
                //BranchTextbox.Text = String.Empty;
                TextBoxNameEmail.Value = String.Empty;
                //RoleTextBox.Text = String.Empty;
                TextBoxNameUName.Value = String.Empty;
                TextBoxNamePhone.Value = String.Empty;

                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin Saved Successfully" + "', function(){location = '/Start/Login.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            //var userDB = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameFName.Value))
                {
                    throw new Exception("First Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameLName.Value))
                {
                    throw new Exception("Last Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameEmail.Value))
                {
                    throw new Exception("Email field is required");
                }
                throw new Exception("User Name field is required");
                if (string.IsNullOrWhiteSpace(TextBoxNamePhone.Value))
                {
                    throw new Exception("Phone No. field is required");
                }
                string           name            = (!string.IsNullOrWhiteSpace(TextBoxNameFName.Value)) ? TextBoxNameFName.Value.Trim() : string.Empty;
                IList <Hospital> theHospitalList = new HospitalDAO().RetrieveByName(name);

                if (theHospitalList.Count <= 0)
                {
                    //create headquarters branch for user
                    Hospital hospital = new Hospital();
                    hospital.Name                 = name;
                    hospital.Address              = TextBoxNameLName.Value;
                    hospital.PrimaryContactEmail  = TextBoxNameEmail.Value;
                    hospital.PrimaryContactNumber = TextBoxNamePhone.Value;
                    HospitalDAO.Save(hospital);
                }

                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "UserName Already Exists!" + "', function(){});</script>", false);
                }


                TextBoxNameFName.Value = String.Empty;
                TextBoxNameLName.Value = String.Empty;
                TextBoxNameEmail.Value = String.Empty;
                TextBoxNamePhone.Value = String.Empty;

                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin Saved Successfully" + "', function(){location = '/Start/Login.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
示例#11
0
 public HospitalController(HospitalDAO hospitalDAO) => _hospitalDAO = hospitalDAO;