Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        dr = Db.LoadAppointment(Convert.ToInt32(Request.QueryString["id"]));

        if (dr == null)
        {
            throw new Exception("The requested time slot was not found");
        }

        if (!IsPostBack)
        {
            TextBoxStart.Text = Convert.ToDateTime(dr["AppointmentStart"]).ToString();
            TextBoxEnd.Text   = Convert.ToDateTime(dr["AppointmentEnd"]).ToString();
            TextBoxName.Text  = dr["AppointmentPatientName"] as string;
            DropDownListStatus.SelectedValue = (string)dr["AppointmentStatus"];

            DropDownListRoom.DataSource     = Db.LoadDoctors();
            DropDownListRoom.DataTextField  = "DoctorName";
            DropDownListRoom.DataValueField = "DoctorId";
            DropDownListRoom.SelectedValue  = Convert.ToString(dr["DoctorId"]);
            DropDownListRoom.DataBind();

            TextBoxName.Focus();
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        if (!IsPostBack)
        {
            DataRow dr = dbGetEvent(Request.QueryString["id"]);

            if (dr == null)
            {
                throw new Exception("The event was not found");
            }

            TextBoxStart.Text     = Convert.ToDateTime(dr["ReservationStart"]).ToShortDateString();
            TextBoxEnd.Text       = Convert.ToDateTime(dr["ReservationEnd"]).ToShortDateString();
            TextBoxStartTime.Text = dr["StartTime"] as string;
            TextBoxEndTime.Text   = dr["EndTime"] as string;
            TextBoxName.Text      = dr["ReservationName"] as string;
            TextBoxUser.Text      = dr["UserName"] as string;

            DropDownListRoom.DataSource     = dbGetResources();
            DropDownListRoom.DataTextField  = "RoomName";
            DropDownListRoom.DataValueField = "RoomId";
            DropDownListRoom.SelectedValue  = Convert.ToString(dr["RoomId"]);
            DropDownListRoom.DataBind();

            DropDownListStatus.SelectedValue = Convert.ToString(dr["ReservationStatus"]);
            DropDownListPaid.SelectedValue   = Convert.ToString(dr["ReservationPaid"]);
            TextBoxName.Focus();
        }
    }
Пример #3
0
        private void ButtonStepTwo_Click(object sender, EventArgs e)
        {
            if (!ValidateStepTwo())
            {
                MessageBox.Show("Preencha os campos necessários.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TextBoxName.Focus();

                return;
            }

            try {
                if (!ValidateDocument())
                {
                    MessageBox.Show("CPF já cadastrado.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    TextBoxName.Focus();

                    return;
                }
            } catch {
                MessageBox.Show("Ocorreu um erro interno, tente novamente mais tarde.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TextBoxName.Focus();

                return;
            }

            Customer.Name     = TextBoxName.Text;
            Customer.Email    = TextBoxEmail.Text;
            Customer.Document = TextBoxDocument.Text;
            Customer.Phone    = TextBoxDocument.Text;

            PanelStepTwo.Visible   = false;
            PanelStepThree.Visible = true;

            AcceptButton = ButtonRegister;
        }
Пример #4
0
        private void ButtonRegister_Click(object sender, EventArgs e)
        {
            if (!ValidateRegister())
            {
                MessageBox.Show("Preencha os campos necessários.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TextBoxName.Focus();

                return;
            }

            Manager.Name     = TextBoxName.Text;
            Manager.Username = TextBoxUsername.Text;
            Manager.Password = TextBoxPassword.Text;
            Manager.Enabled  = true;

            Manager.CreatedAt = DateTime.Now;
            Manager.UpdatedAt = DateTime.Now;

            try {
                DAO.Managers.Add(Manager);

                MessageBox.Show("Bem-vindo a Prophet Shop, " + Manager.Name + "!", "", MessageBoxButtons.OK);

                Close();
            } catch {
                MessageBox.Show("Ocorreu um erro interno, tente novamente mais tarde.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TextBoxUsername.Focus();

                return;
            }
        }
Пример #5
0
        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            int count = StackPanelContainer.Children.Count;

            if (e.Key == Key.Down && count > 0 && StackPanelContainer.Children[count - 1].IsFocused)
            {
                StackPanelContainer.Children[0].Focus();
                e.Handled = true;
            }
            else if (e.Key == Key.Up && count > 0 && StackPanelContainer.Children[0].IsFocused)
            {
                StackPanelContainer.Children[count - 1].Focus();
                e.Handled = true;
            }
            else if (e.Key == Key.Escape)
            {
                TextBoxName.Clear();
            }
            else if (e.Key == Key.Enter)
            {
                if (count == 1)
                {
                    IndexButton indexButton = StackPanelContainer.Children[0] as IndexButton;
                    indexButton.IndexButtonClick(indexButton, null);
                }
            }
            else if (e.Key != Key.Up && e.Key != Key.Down)
            {
                TextBoxName.Focus();
            }
        }
        public AddElementWindow(string insertedId = "", bool addElement = true,
                                WarehouseItem warehouseItemToModify = null)
        {
            InitializeComponent();
            AddElement = addElement;

            if (!AddElement)
            {
                TextBoxCode.IsReadOnly = true;

                if (warehouseItemToModify == null)
                {
                    return;
                }
                TextBoxName.Text     = warehouseItemToModify.Name;
                TextBoxCode.Text     = warehouseItemToModify.Id;
                TextBoxPrice.Text    = warehouseItemToModify.Price.ToString("0.00");
                TextBoxQuantity.Text = warehouseItemToModify.Quantity.ToString();
                TextBoxName.Focus();
            }
            else
            {
                if (string.IsNullOrEmpty(insertedId))
                {
                    TextBoxCode.Focus();
                }
                else
                {
                    TextBoxCode.Text       = insertedId;
                    TextBoxCode.IsReadOnly = true;
                    TextBoxName.Focus();
                }
            }
        }
 private void ShowEditBox()
 {
     TextBoxName.Visibility = Windows.UI.Xaml.Visibility.Visible;
     PageTitle.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
     TextBoxName.Focus(Windows.UI.Xaml.FocusState.Programmatic);
     TextBoxName.SelectAll();
 }
        private bool CheckedUser()
        {
            String strName = TextBoxName.Text.Trim();

            if (_strDic.Count > 0 && _strDic.ContainsKey(strName))
            {
                MessageBox.Show("用户名【" + strName + "】已经存在,请重新输入!", "操作提示");
                return(false);
            }

            if (!strName.Equals("260905"))
            {
                if (strName.Equals(string.Empty))
                {
                    TextBoxName.Clear();
                    TextBoxName.Focus();
                    MessageBox.Show("用户名不能为空!", "操作提示");
                    return(false);
                }
                else if (TextBoxPassword.Text.Trim().Equals(string.Empty))
                {
                    TextBoxPassword.Clear();
                    TextBoxPassword.Focus();
                    MessageBox.Show("密码不能为空!", "操作提示");
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("不能创建该用户!", "操作提示");
                return(false);
            }
            return(true);
        }
Пример #9
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            if (TextBoxName.Text == string.Empty)
            {
                TextBoxName.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Saisissez le nom"));
                return;
            }

            if (TextBoxInitialAmount.Text == string.Empty)
            {
                TextBoxInitialAmount.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Entrez la valeur initiale"));
                return;
            }

            string name         = TextBoxName.Text;
            Double initialValue = Double.Parse(TextBoxInitialAmount.Text, NumberStyles.Currency);

            control.SaveAccount(name, initialValue);
            LoadAccounts();

            TextBoxName.Text          = string.Empty;
            TextBoxInitialAmount.Text = string.Empty;
        }
Пример #10
0
        bool IsValid()
        {
            bool isValid = true;

            if (string.IsNullOrEmpty(TextBoxName.Text.CleanText()))
            {
                isValid = false;
                SystemMessages sm = new SystemMessages(new Message()
                {
                    UserMessage = "Invalid Name", SystemMessage = "Please provide valid Name.", UserMessageType = MessageType.Error
                },
                                                       ButtonType.OkOnly);
                sm.Closed += new EventHandler(delegate(object sender, EventArgs e)
                {
                    TextBoxName.Focus();
                });
#if !SILVERLIGHT
                sm.Owner = Window.GetWindow(this);
#endif
                sm.ShowPopup();
                return(isValid);
            }

            return(isValid);
        }
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            var messageQueue = SnackbarThree.MessageQueue;

            if (TextBoxName.Text == string.Empty)
            {
                TextBoxName.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe o nome"));
                return;
            }

            if (TextBoxValue.Text == string.Empty)
            {
                TextBoxValue.Focus();
                Task.Factory.StartNew(() => messageQueue.Enqueue("Informe o valor"));
                return;
            }

            string   name     = TextBoxName.Text;
            Double   value    = Double.Parse(TextBoxValue.Text, NumberStyles.Currency);
            DateTime deadline = DatePickerDeadline.SelectedDate ?? DateTime.Now;

            control.SaveGoal(name, value, deadline);
            LoadGoals();

            TextBoxName.Text        = string.Empty;
            TextBoxValue.Text       = string.Empty;
            DatePickerDeadline.Text = string.Empty;

            LoadBox();
        }
Пример #12
0
        private async void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(TextBoxName.Text) || !string.IsNullOrWhiteSpace(Password.Password))
            {
                var metroWindow = (Window.GetWindow(this) as MetroWindow);
                try
                {
                    await _electionConfigurationService.SaveCommissionerAsync(new Commissioner
                    {
                        FullName    = TextBoxName.Text,
                        UserName    = Username.Text,
                        Password    = Password.Password,
                        IsChairman  = Convert.ToBoolean(IsChairman.IsChecked),
                        IsPresident = Convert.ToBoolean(IsPresident.IsChecked)
                    });

                    await metroWindow.ShowMessageAsync("Success !", $"{Username.Text} Successfully created");

                    Util.Clear(this);
                    TextBoxName.Focus();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                    await metroWindow.ShowMessageAsync("Wait !", "Something Went Wrong");
                }
            }
        }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.accountId      = Common.GetEncryptedQueryStringValue("AccountId", 0);
            LabelPageTitle.Text = (this.accountId == 0) ? "New Account" : "Edit Account";

            Page.Form.DefaultFocus  = TextBoxName.ClientID;
            Page.Form.DefaultButton = ButtonSave.UniqueID;

            if (!IsPostBack)
            {
                TextBoxName.Focus();

                BindAccountType();
                BindAccountStatus();

                ButtonSave.Visible              = true;
                ButtonSaveNew.Visible           = true;
                ButtonAddAccountContact.Visible = false;

                if (ViewState["AccountId"] != null)
                {
                    this.accountId = Convert.ToInt32(ViewState["AccountId"].ToString());
                }
                if (this.accountId != 0)
                {
                    BindAccount();
                    ButtonAddAccountContact.Visible = true;
                    BindAccountContactGridView();
                }
            }
        }
Пример #14
0
        public void ButtonEdit_Click(object sender, EventArgs e)
        {
            if (ButtonEdit.Content.Equals("Edit")) // .Equals is required instead of ==
            {
                ButtonEdit.Background = brush2;
                ButtonEdit.Content    = "Save";
                // enable text boxes to be edited
                TextBoxName.IsReadOnly = false;
                TextBoxAge.IsReadOnly  = false;
                // change the colour of the textboxes while they are being edited
                TextBoxAge.Background  = (SolidColorBrush)Brushes.White;
                TextBoxName.Background = (SolidColorBrush)Brushes.White;
                // to keep the add button disabled
                ButtonAdd.IsEnabled = false;
                // to highlight the text of the rabbit name
                TextBoxName.Focus();
                TextBoxName.SelectAll();
            }
            else
            {
                ButtonEdit.Background = brush3;
                ButtonEdit.Content    = "Edit";
                if ((TextBoxAge.Text.Length > 0) && (TextBoxName.Text.Length > 0))
                {
                    // must have selected a rabbit
                    if (rabbit != null)
                    {
                        rabbit.Name = TextBoxName.Text;
                        if (int.TryParse(TextBoxAge.Text, out int age))
                        {
                            rabbit.AGE = age;
                        }

                        using (var db = new RabbitDbEntities())
                        {
                            // read rabbit from database by ID
                            var rabbitToUpdate = db.Rabbits.Find(rabbit.RabbitId);
                            // read rabbit
                            rabbitToUpdate.Name = rabbit.Name;
                            rabbitToUpdate.AGE  = rabbit.AGE;
                            // save rabbit back to db
                            db.SaveChanges();
                            // clear listbox because we're going to change (the binding)
                            rabbit = null; // remove the binding rabbit
                            // ListBoxRabbit.ItemsSource = null; // remove binding
                            //ListBoxRabbit.Items.Clear();    // clear it out
                            // repopulate listbox // re-read from db
                            rabbits = db.Rabbits.ToList();       // get rabbits
                            ListBoxRabbit.ItemsSource = rabbits; // bind to listbox again
                        }
                    }
                    //TextBoxAge.Text = "";
                    //TextBoxName.Text = "";
                    TextBoxAge.IsReadOnly  = true;
                    TextBoxName.IsReadOnly = true;
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Verify that the user's account exists on the Unity Connection server and that they have administrator rights.  The login
        /// to CUPI for admins will fail otherwise.
        /// If the login goes through add the user information to the session variable - this doesn't get used for anything other than
        /// as verification that the currently logged in user is authenticated - the credentials have to be resent with each CUPI command
        /// regardless.  This just makes sure the user isn't getting cute and going directly to the user selection page.
        /// </summary>
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            ConnectionServerRest currentConnectionServer;

            //check for empty strings - yes, you can use ASP form control checks for these but then you have difficulty with the Java Script
            //method of enabling/disabling the login button on the client side so I do the checks manually here and just use a single status
            //label for feedback - not quite as slick but the trade off is worth it.
            if (string.IsNullOrEmpty(TextBoxServerName.Text.Trim()))
            {
                LabelStatus.Text = "You must provide a Connection server name";
                TextBoxServerName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(TextBoxName.Text.Trim()))
            {
                LabelStatus.Text = "You must provide a login name";
                TextBoxName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(TextBoxPassword.Text.Trim()))
            {
                LabelStatus.Text = "You must provide a password";
                TextBoxPassword.Focus();
                return;
            }

            LabelStatus.Text = "";

            try
            {
                currentConnectionServer = new ConnectionServerRest(new RestTransportFunctions(), TextBoxServerName.Text.Trim(), TextBoxName.Text.Trim(),
                                                                   TextBoxPassword.Text.Trim());
            }
            catch
            {
                LabelStatus.Text    = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid";
                ButtonLogin.Enabled = true;
                return;
            }

            //if the class creation failed but the server login still didn't complete (this should really never happen, but just in case)
            if (currentConnectionServer.ServerName.Length == 0)
            {
                //login failed = give the user the chance to try again.
                LabelStatus.Text    = "Login failed, make sure the server name is valid, DNS is working properly and the user name and login are valid";
                ButtonLogin.Enabled = true;
                return;
            }

            //stuff the current connection server object into the session state where we can pull it out later.  Then redirect to the select user
            //page which is where all the action takes place.
            Session["CurrentConnectionServer"] = currentConnectionServer;
            Response.Redirect("~/SelectUser.aspx");
        }
Пример #16
0
        private void metroTileEnter_Click(object sender, EventArgs e)
        {
            SimsOracle db   = new SimsOracle();
            int        rows = 0;

            if (TextBoxName.Text == "")
            {
                MessageBox.Show("You should enter centre name");
                TextBoxName.Focus();
            }
            else if (TextBoxAddress.Text == "")
            {
                MessageBox.Show("You should enter centre address");
                TextBoxAddress.Focus();
            }
            else if (TextBoxClasses.Text == "")
            {
                MessageBox.Show("You should enter number of classes");
                TextBoxClasses.Focus();
            }
            else if (!checkValue.isValidInteger(TextBoxClasses.Text))
            {
                MessageBox.Show("The number format is not valid");
                TextBoxClasses.Focus();
            }
            else
            {
                try
                {
                    string sql = "INSERT INTO CENTRE " +
                                 "(NAME, ADDRESS, CLASSES) " +
                                 " VALUES " +
                                 "(:NAME, :ADDRESS, :CLASSES)";
                    OracleCommand cmd = new OracleCommand(sql, db.Connection);
                    cmd.Parameters.Add("NAME", TextBoxName.Text);
                    cmd.Parameters.Add("ADDRESS", TextBoxAddress.Text);
                    cmd.Parameters.Add("CLASSES", TextBoxClasses.Text);

                    rows = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error adding a centre:\n" + ex.Message.ToString());
                }
                if (rows > 0)
                {
                    MessageBox.Show("Centre added successfully");
                    ClearControls();
                }
                else
                {
                    MessageBox.Show("Centre was not added, there might have been unexpected error");
                }
            }
        }
Пример #17
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            if (ButtonEdit.Content.Equals("Edit"))
            {
                Color color = (Color)ColorConverter.ConvertFromString("#007ED9");
                var   brush = new SolidColorBrush(color);

                ButtonEdit.Background = brush;
                ButtonEdit.Content    = "Save";

                TextBoxName.IsReadOnly = false;
                TextBoxAge.IsReadOnly  = false;

                ButtonAdd.IsEnabled = false;
                TextBoxName.Focus();
                TextBoxName.SelectAll();
            }
            else
            {
                ButtonEdit.Content = "Edit";
                if ((TextBoxAge.Text.Length > 0) && (TextBoxName.Text.Length > 0))
                {
                    if (rabbit != null)
                    {
                        rabbit.Name = TextBoxName.Text;
                        if (int.TryParse(TextBoxAge.Text, out int age))
                        {
                            rabbit.Age = age;
                        }


                        using (var db = new RabbitDbEntities())
                        {
                            //read rabbit from database by the ID
                            var rabbitToUpdate = db.Rabbits.Find(rabbit.RabbitId);
                            //update the rabbit and save it back to DB
                            rabbitToUpdate.Name = rabbit.Name;
                            rabbitToUpdate.Age  = rabbit.Age;
                            //save it back to db
                            db.SaveChanges();
                            //Clear list box because we will change it
                            rabbit = null;
                            ListBoxRabbit.ItemsSource = null; //remove binding
                            ListBoxRabbit.Items.Clear();      //clears it

                            //repopulate list box
                            rabbits = db.Rabbits.ToList();
                            ListBoxRabbit.ItemsSource = rabbits;
                        }
                    }
                }
                ButtonAdd.IsEnabled = false;
            }
        }
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            if (ButtonEdit.Content.Equals("Edit"))
            {
                // Color color = (Color)ColorConverter.ConvertFromString("#FF1D3A");
                ButtonEdit.Content     = "Save";
                ButtonEdit.Background  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF1D3A"));
                TextBoxAge.IsReadOnly  = false;
                TextBoxName.IsReadOnly = false;
                ButtonAdd.IsEnabled    = false;

                TextBoxName.Focus();
                TextBoxName.SelectAll();
            }
            else //Save mode
            {
                ButtonEdit.Background  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E8C3E3"));
                ButtonEdit.Content     = "Edit";
                TextBoxAge.IsReadOnly  = true;
                TextBoxName.IsReadOnly = true;

                if (TextBoxAge.Text.Length > 0 && TextBoxName.Text.Length > 0)
                {
                    //must have a rabbit selected
                    if (rabbit != null)
                    {
                        rabbit.Name = TextBoxName.Text;
                        if (int.TryParse(TextBoxAge.Text, out int age))
                        {
                            rabbit.Age = age;
                        }

                        //Read Rabbit from database by the ID
                        using (var db = new RabbitDbEntities())
                        {
                            //Read Rabbit from database by the ID
                            var rabbitToUpdate = db.Rabbits.Find(rabbit.RabbitId);
                            //UPDATE rabbit, save it back to the database
                            rabbitToUpdate.Name = rabbit.Name;
                            rabbitToUpdate.Age  = rabbit.Age;
                            db.SaveChanges();
                            //CLEAR listbox - Remove binding, Clear it out
                            //rabbit = null;
                            //listBoxRabbits.ItemsSource = null;
                            //listBoxRabbits.Items.Clear();
                            //REPOPULATE - get rabbits, bind
                            rabbits = db.Rabbits.ToList();
                            listBoxRabbits.ItemsSource = rabbits;
                        }
                    }
                    ButtonAdd.IsEnabled = true;
                }
            }
        }
Пример #19
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            TextBoxName.Focus();

            if (IsEditMode)
            {
                var genreInformation = _connectionManager.GetDataTable(CommandFactory.GetGenreInformation(_genreId)).Rows[0];

                TextBoxName.Text = genreInformation["genre_name"].ToString();
                TextBoxName.Select(TextBoxName.Text.Length, 0);
            }
        }
Пример #20
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     TextBoxName.Focus(FocusState.Programmatic);
     if (Group.ID == 0)
     {
         ApplicationView.GetForCurrentView().Title = "Создание группы";
     }
     else
     {
         ApplicationView.GetForCurrentView().Title = "Группа";
     }
 }
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            if (ButtonEdit.Content.Equals("Edit"))
            {
                ButtonEdit.Background  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#9589FF"));
                ButtonEdit.Content     = "Save";
                TextBoxName.IsReadOnly = false;
                TextBoxAge.IsReadOnly  = false;
                TextBoxName.Background = (SolidColorBrush)Brushes.White;
                TextBoxAge.Background  = (SolidColorBrush)Brushes.White;
                ButtonAdd.IsEnabled    = false;
                TextBoxName.Focus();
                TextBoxName.SelectAll();
            }
            else
            {
                Color color = (Color)ColorConverter.ConvertFromString("#B3C6ED");
                var   brush = new SolidColorBrush(color);
                ButtonEdit.Background = brush;
                ButtonEdit.Content    = "Edit";
                if ((TextBoxAge.Text.Length > 0) && (TextBoxName.Text.Length > 0))
                {
                    // must have selected a rabbit
                    if (rabbit != null)
                    {
                        rabbit.Name = TextBoxName.Text;
                        if (int.TryParse(TextBoxAge.Text, out int age))
                        {
                            rabbit.Age = age;
                        }

                        using (var db = new RabbitDbEntities())
                        {
                            // read rabbit from database by ID
                            var rabbitToUpdate = db.Rabbits.Find(rabbit.RabbitId);
                            // update rabbit
                            rabbitToUpdate.Name = rabbit.Name;
                            rabbitToUpdate.Age  = rabbit.Age;
                            // save rabbit back to DB
                            db.SaveChanges();
                            // clear listbox because we're going to change (the binding)
                            rabbit = null;  // remove binding on rabbit
                            // ListBoxRabbits.ItemsSource = null;  // remove binding
                            // ListBoxRabbits.Items.Clear();       // clear it out
                            // repopulate listbox // re-read from db
                            rabbits = db.Rabbits.ToList();                // get rabbits
                            ListBoxRabbits.ItemsSource = rabbits;         // bind to listbox again
                        }
                    }
                }
                ButtonAdd.IsEnabled = true;
            }
        }
Пример #22
0
        public FormSavePlaylist(ISaveSupport aSaveSupport)
        {
            InitializeComponent();

            iSaveSupport = aSaveSupport;

            Size = new System.Drawing.Size(470, 123);

            TextBoxName.Text = aSaveSupport.DefaultName;
            TextBoxName.SelectAll();
            TextBoxName.Focus();
        }
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Hey, we're adding homie");
            if (ButtonAdd.Content.Equals("Add"))
            {
                ButtonAdd.Content      = "Save";
                ButtonAdd.Background   = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF1D3A"));
                TextBoxName.Text       = "";
                TextBoxAge.Text        = "";
                TextBoxName.Background = (SolidColorBrush)Brushes.White;
                TextBoxAge.Background  = (SolidColorBrush)Brushes.White;

                TextBoxName.IsReadOnly = false;
                TextBoxAge.IsReadOnly  = false;

                ButtonEdit.IsEnabled = false;
                ButtonDel.IsEnabled  = false;

                TextBoxName.Focus();
            }
            else
            {
                ButtonAdd.Content    = "Add";
                ButtonAdd.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#E8C3E3"));
                //Clear out boxes, set to white
                TextBoxName.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFD6E5"));
                TextBoxAge.Background  = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FFD6E5"));
                TextBoxName.IsReadOnly = true;
                TextBoxAge.IsReadOnly  = true;

                if (TextBoxName.Text.Length > 0 && TextBoxAge.Text.Length > 0)
                {
                    //get age
                    if (int.TryParse(TextBoxAge.Text, out int age))
                    {
                        var RabbitToAdd = new Rabbit()
                        {
                            Name = TextBoxName.Text,
                            Age  = age
                        };

                        using (var db = new RabbitDbEntities())
                        {
                            db.Rabbits.Add(RabbitToAdd);
                            db.SaveChanges();
                            rabbits = db.Rabbits.ToList();
                            listBoxRabbits.ItemsSource = rabbits;
                        }
                    }
                }
            }
        }
Пример #24
0
 private void ButtonEdit_Click(object sender, EventArgs e)
 {
     TextBoxName.Enabled     = true;
     TextBoxUsername.Enabled = true;
     TextBoxPassword.Enabled = true;
     ComboBoxRole.Enabled    = true;
     ButtonNew.Enabled       = false;
     ButtonEdit.Enabled      = true;
     ButtonSave.Enabled      = true;
     ButtonDelete.Enabled    = false;
     TextBoxPassword.Clear();
     _save = false;
     TextBoxName.Focus();
 }
Пример #25
0
        public Index()
        {
            InitializeComponent();

            string win32ToolTip = "";

            foreach (HardwareEnum hardwareEnum in Enum.GetValues(typeof(HardwareEnum)))
            {
                win32ToolTip += hardwareEnum.ToString() + "\r\n";
            }
            Win32HardwareInfos.ToolTip = win32ToolTip.Trim();

            TextBoxName.Focus();
        }
Пример #26
0
 private void ButtonNew_Click(object sender, EventArgs e)
 {
     TextBoxName.Enabled     = true;
     TextBoxUsername.Enabled = true;
     TextBoxPassword.Enabled = true;
     ComboBoxRole.Enabled    = true;
     ButtonEdit.Enabled      = false;
     ButtonSave.Enabled      = true;
     ButtonDelete.Enabled    = false;
     TextBoxName.Text        = "";
     TextBoxUsername.Text    = "";
     TextBoxPassword.Text    = "";
     _userId = "";
     TextBoxName.Focus();
 }
Пример #27
0
        /// <summary>
        /// The Method that get called on Page Load Event
        /// </summary>
        /// <param name="sender">Event Source</param>
        /// <param name="eventArgument">Event Data</param>
        protected void Page_Load(object sender, EventArgs eventArgument)
        {
            DataProvider.AuthorizeUser();
            MasterPage masterPage = this.Page.Master;
            Header     headerPage = (Header)masterPage;

            headerPage.DisplayDataFromMasterPage(Session["UserName"].ToString());
            headerPage.DisplayProductSelectionControl(false);

            if (!Page.IsPostBack)
            {
                LabelRequiredFields.Text = Resources.Labels.RequiredFields;
                GetCountries();
                GetCompanies();
                GetProducts();
                DropDownListCountry.Attributes.Add("onChange", "javascript:GetStates('" + DropDownListCountry.ClientID + "', '" + HiddenFieldStateSource.ClientID + "', '" + HiddenFieldStateOthers.ClientID + "', '" + HiddenFieldState.ClientID + "')");
                BuildCountriesAndStates();
                if (Request.QueryString["action"] != null)
                {
                    if (Request.QueryString["action"] == "update")
                    {
                        userId             = Request.Form["USR_ID"].ToString();
                        HiddenUserId.Value = userId;
                        // Display update Button
                        ButtonUpdate.Visible = true;
                        GetUserDetails();
                    }
                    else
                    {
                        ButtonAdd.Visible = true;
                    }
                }


                //Edit Profile

                if (Request.Params["EditProfile"] != null)
                {
                    userId             = Session["UserID"].ToString();
                    HiddenUserId.Value = userId;
                    // Display update Button
                    ButtonUpdate.Visible = true;
                    ButtonAdd.Visible    = false;
                    GetUserDetails();
                }
            }
            TextBoxName.Focus();
        }
Пример #28
0
 private bool IsValidData()
 {
     if (string.IsNullOrEmpty(TextBoxName.Text))
     {
         Globals.MessageBoxShow(this, "Please Enter Name");
         TextBoxName.Focus();
         return(false);
     }
     if (string.IsNullOrEmpty(TextBoxDesc.Text))
     {
         Globals.MessageBoxShow(this, "Please Enter Description");
         TextBoxDesc.Focus();
         return(false);
     }
     return(true);
 }
Пример #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TextBoxStart.Text = Convert.ToDateTime(Request.QueryString["start"]).ToShortDateString();
            TextBoxEnd.Text   = Convert.ToDateTime(Request.QueryString["end"]).ToShortDateString();

            TextBoxName.Focus();

            DropDownList1.DataSource     = dbGetResources();
            DropDownList1.DataTextField  = "RoomName";
            DropDownList1.DataValueField = "RoomId";
            DropDownList1.SelectedValue  = Request.QueryString["r"];
            DropDownList1.DataBind();
        }
    }
Пример #30
0
 private void ButtonCreate_Click(object sender, EventArgs e)
 {
     PresentationLayerClass.EnableDisableButtons(new Button[] {
         ButtonSave, ButtonClear
     }, true);
     PresentationLayerClass.EnableDisableButtons(new Button[] {
         ButtonDelete, ButtonCreate, ButtonEdit
     }, false);
     PresentationLayerClass.OnlyReadSwitch(panel1, 1, false);
     TextBoxRoomsCount.ReadOnly = true;
     dataGridView1.Enabled      = false;
     ButtonCancelEdit.Visible   = true;
     PresentationLayerClass.ClearBeforeCreate(panel1, dataGridView1);
     FlagSelectedRow = true;
     TextBoxName.Focus();
 }