Beispiel #1
0
 //Method to add data from datagrid row to corresponding textboxes
 private void InitItems()
 {
     try
     {
         employeeIDTextBox.Text    = dataGridHours[0, 0].Value.ToString();
         ActivityIDTextBox.Text    = dataGridHours[1, 0].Value.ToString();
         dateTextBox.Text          = dataGridHours[2, 0].Value.ToString();
         durationTextBox.Text      = dataGridHours[3, 0].Value.ToString();
         locationTextBox.Text      = dataGridHours[4, 0].Value.ToString();
         hoursApprovedTextBox.Text = dataGridHours[5, 0].Value.ToString();
         descriptionTextBox.Text   = dataGridHours[6, 0].Value.ToString();
         IDTextBox.Text            = dataGridHours[7, 0].Value.ToString();
     }
     catch
     {
         employeeIDTextBox.Clear();
         ActivityIDTextBox.Clear();
         dateTextBox.Clear();
         durationTextBox.Clear();
         locationTextBox.Clear();
         descriptionTextBox.Clear();
         hoursApprovedTextBox.Clear();
         IDTextBox.Clear();
     }
 }
Beispiel #2
0
        private void reset()
        {
            bindingDateGridView();
            restoreDateGridView();
            IDTextBox.Clear();
            textBoxName.Clear();
            quantityTextBox.Clear();
            conductTimePicker.Value = DateTime.Today;
            empIDTextBox.Clear();
            textBoxMax.Clear();
            notify = ctr.getEmptyStock();
            var stocksName = "";

            if (notify.Count > 0)
            {
                // use iterator
                foreach (var item in notify)
                {
                    stocksName += item + " " + "+";
                }
                labelNotify.Text = stocksName + "is empty now, need to restore.\n";
            }
            else
            {
                labelNotify.Text = "All items are in stock. ";
            }
        }
Beispiel #3
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (NameTextBox.Text == "")
            {
                MessageBox.Show("Employee name not entered.");
                NameTextBox.Focus();
                return;
            }

            int IDNumber;

            try {
                IDNumber = int.Parse(IDTextBox.Text);
            } catch {
                MessageBox.Show("Invalid Employee ID.");
                IDTextBox.Focus();
                return;
            }

            myEmployee.NewEmployee(NameTextBox.Text, IDNumber, DepartmentTextBox.Text, PositionTextBox.Text);

            NameTextBox.Clear();
            IDTextBox.Clear();
            DepartmentTextBox.Clear();
            PositionTextBox.Clear();

            ListBox.Items.Add("Employee: " + IDNumber + " added!");

            NameTextBox.Focus();
        }
Beispiel #4
0
        private void FindButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                func();
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message);
            }
            try
            {
                t = myBL.Get_tester(IDTextBox.Text);
                UpdateTesterGrid.DataContext = t;
                AddressTextBox.Text          = t.Address.ToString();
                t.Copy(arr, t.Schedule);
                IDTextBox.IsReadOnly   = true;
                NextButton.IsEnabled   = true;
                DeleteButton.IsEnabled = true;
                UpButton1.IsEnabled    = true;

                MaxSeniority = DateTime.Now.Year - t.Date_of_birth.Year - 40;
                if (MaxSeniority != 0)
                {
                    UpButton2.IsEnabled = true;
                }
            }
            catch (Exception E)
            {
                MessageBox.Show(E.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
                IDTextBox.Clear();
            }
        }
Beispiel #5
0
 private void reset()
 {
     bindingDateGridView();
     IDTextBox.Clear();
     textBoxName.Clear();
     phoneTextBox.Clear();
     textBoxAddress.Clear();
 }
Beispiel #6
0
 private void SignInButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (IDTextBox.PasswordChar == '*')
         {
             if (Program.TryAuthenticate(IDTextBox.Text, NameTextBox.Text))
             {
                 Application.Exit();
             }
             else
             {
                 throw new Exception("管理员登陆失败!");
             }
         }
         if ((IDTextBox.Text.Count() != 9) || !IsNumeric(IDTextBox.Text))
         {
             throw new Exception("请输入正确的学号。");
         }
         int result = Student.SplitIsOK(int.Parse(IDTextBox.Text), NameTextBox.Text);
         if (result == -99)
         {
             throw new Exception("请检查学号和姓名是否输入错误。");
         }
         if (result == 99)
         {
             throw new Exception("分流系统运行中,请自习的同学于上课15分钟后再尝试登陆!");
         }
         if (result > 0)
         {
             Student.CheckIsOK(int.Parse(IDTextBox.Text));
             Normal normal = new Normal(new Student(int.Parse(IDTextBox.Text), true));
             normal.Show();
             Hide();
         }
         if (--result < 0)
         {
             Print.Infomsg("分流系统登陆成功,稍后将尝试为你自动签到,你可以开始你的学习了!\n若到上课时间仍没有自动签到,请使用桌面上的签到程序手动签到。", "登陆成功");
             Hide();
             CheckInTimer.Interval = -result * 60 * 1000;
             CheckInTimer.Enabled  = true;
             ExitTimer.Enabled     = false;
         }
     }
     catch (Exception ex)
     {
         IDTextBox.Text           = "";
         NameTextBox.Text         = "";
         IDTextBox.PasswordChar   = new char();
         NameTextBox.PasswordChar = new char();
         IDTextBox.Focus();
         Print.Show(ex.Message);
     }
     finally
     {
         Program.conn.Close();
     }
 }
        //更新反序列信息
        public void ShowAllBook()
        {
            Thread thread = new Thread(threadStart);

            thread.Start();
            IDTextBox.Clear();
            NameTextBox.Clear();
            thread.Abort();
        }
Beispiel #8
0
 private void ClearAllToolBoxs()
 {
     IDTextBox.Clear();
     ExpDateTimePicker.CustomFormat = " ";
     CatagoryComboBox.SelectedIndex = -1;
     SearchTextBox.Clear();
     AmountTextBox.Clear();
     ExpDescTextBox.Clear();
     IDTextBox.Focus();
     GetAllExpances();
 }
Beispiel #9
0
 private void reset()
 {
     bindingDateGridView();
     IDTextBox.Clear();
     textBoxName.Clear();
     addressTextBox.Clear();
     dateTimePickerDob.Value = DateTime.Today;
     emailTextBox.Clear();
     phoneTextBox.Clear();
     textBoxPassword.Clear();
     textBoxConfirm.Clear();
 }
Beispiel #10
0
 private void IDCueText_Click(object sender, EventArgs e)
 {
     if (IDTextBox.Text.Trim() == "")
     {
         IDCueText.Hide();
     }
     else if (IDTextBox.Text.Trim() != "" && IDCueText.Visible == false)
     {
         IDCueText.Hide();
     }
     IDTextBox.Focus();
 }
Beispiel #11
0
        private void IDTextBox_TextChanged(object sender, EventArgs e)
        {
            if (Loading)
            {
                return;
            }
            int cursorpos = IDTextBox.SelectionStart;

            ((CameraEditorForm)ParentForm).RefreshSelected(IDTextBox.Text);
            IDTextBox.Focus();
            IDTextBox.SelectionStart  = cursorpos;
            IDTextBox.SelectionLength = 0;
        }
        // Precondition: Must have either letters or nothing in the textbox
        // Postcondition: Validates the id textbox and sends a warning
        private void IDTextBox_Validating(object sender, CancelEventArgs e)
        {
            int id;           // number that comes out of tryparse
            int negative = 0; // negative magic number test

            if (!int.TryParse(IDTextBox.Text, out id) ||
                Convert.ToInt32(IDTextBox.Text) < negative)
            {
                e.Cancel = true;

                errorProvider2.SetError(IDTextBox, "Enter an ID!");

                IDTextBox.SelectAll();
            }
        }
        // Clear UI infput fields
        private void ClearUI()
        {
            IDTextBox.Clear();
            UserNameTextBox.Clear();
            PasswordTextBox.Clear();
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            EmailTextBox.Clear();
            var date = new DateTime();

            date = DateTime.Today;
            StartDateDatePickerTextBox.Text = date.ToShortDateString();
            UserTypeComboBox.Text           = "Staff";
            ProtectedUserCheckBox.IsChecked = false;
            UserInactiveCheckBox.IsChecked  = false;
        }
Beispiel #14
0
 private void FindButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         t = myBL.Get_trainee(IDTextBox.Text);
         UpdateTraineeGrid.DataContext = t;
         AddressTextBox.Text           = t.Address.ToString();
         IDTextBox.IsReadOnly          = true;
         UpdateButton.IsEnabled        = true;
         DeleteButton.IsEnabled        = true;
         UpButton.IsEnabled            = true;
     }
     catch (Exception E)
     {
         MessageBox.Show(E.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
         IDTextBox.Clear();
     }
 }
Beispiel #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (numTextBox.Text != "" && nameTextBox.Text != "" && FIDTextBox.Text != "" && IDTextBox.Text != "" && colourTextBox.Text != "" && versionTextBox.Text != "" && deployTextBox.Text != "")
            {
                string find          = "SELECT * FROM 源数据 WHERE  零部件代码=" + "'" + IDTextBox.Text.Trim().ToString().ToUpper() + "'";
                string ID            = IDTextBox.Text.ToString().Trim().ToUpper();      //零部件代码
                string number        = numTextBox.Text.ToString().Trim().ToUpper();     //零部件编号
                string name          = nameTextBox.Text.ToString().Trim().ToUpper();    //产品名称
                string version       = versionTextBox.Text.ToString().Trim().ToUpper(); //型号
                string factory       = FIDTextBox.Text.ToString().Trim().ToUpper();     //工厂代码
                string colour        = colourTextBox.Text.ToString().Trim().ToUpper();  //颜色
                string deploy        = deployTextBox.Text.ToString().Trim().ToUpper();  //配置
                string nameAndDeploy = name + "-" + deploy;                             //名称和配置

                string insert = "INSERT INTO 源数据(产品名称,颜色,零部件编号,型号,工厂代码,零部件代码,产品名称配置,配置) values('" + name + "','" + colour + "','" + number + "','" + version + "','" + factory + "','" + ID + "','" + nameAndDeploy + "','" + deploy + "')";
                bool   flag   = databseoperate.AddBarcode(find, insert);
                if (flag == true)
                {
                    this.groupBox1.Show();
                    groupBox1.Text      = "添加成功!!";
                    groupBox1.ForeColor = Color.Blue;
                }
                else
                {
                    this.groupBox1.Show();
                    groupBox1.Text      = "添加失败~~";
                    groupBox1.ForeColor = Color.Red;
                }
            }
            else
            {
                this.groupBox1.Show();
                groupBox1.Text      = "数据输入不全,添加失败~~";
                groupBox1.ForeColor = Color.Red;
            }

            versionTextBox.Clear();
            colourTextBox.Clear();
            IDTextBox.Clear();
            numTextBox.Clear();
            nameTextBox.Clear();
            deployTextBox.Clear();
        }
        //刷新界面
        public void ShowAllBook()
        {
            Thread thread = new Thread(threadStart);

            thread.Start();

            IDTextBox.Clear();
            NameTextBox.Clear();
            AgeTextBox.Clear();
            SexTextBox.Clear();
            EthnicTextBox.Clear();
            BrithdayTextBox.Clear();
            RegistTextBox.Clear();

            for (int i = 0; i < remineder.Count; i++)
            {
                int j = i + 1;
                UserDataGridView.Rows.Add(j.ToString(), remineder[i].ID, remineder[i].name, remineder[i].age, remineder[i].sex, remineder[i].ethnic, remineder[i].brithday, remineder[i].register);
            }
            thread.Abort();
        }
 private void AddButton_Click(object sender, EventArgs e)
 {
     try
     {
         if ((DueñoTextBox.Text != "") && (HorarioTextBox.Text != "") && (IDTextBox.Text != "") && (TipoTextBox.Text != ""))
         {
             OnAddButtonClicked(DueñoTextBox.Text, HorarioTextBox.Text, Convert.ToInt32(IDTextBox.Text), TipoTextBox.Text);
             DueñoTextBox.ResetText();
             HorarioTextBox.ResetText();
             IDTextBox.ResetText();
             TipoTextBox.ResetText();
             stackpanels.RemoveAt(stackpanels.Count - 1);
         }
         else
         {
             MessageBox.Show("Porfavor rellene los campos");
         }
     }
     catch (SystemException)
     {
         MessageBox.Show("Error, el valor del ID es numerico.");
     }
     ShowLastPanel();
 }
Beispiel #18
0
        private void LogInbtn_Click(object sender, EventArgs e)
        {
            string loginid = IDTextBox.Text;
            string loginpw = PWTextBox.Text;
            string strconn = "Server=localhost;Database=test;User Id=root;Password=1234;Charset=utf8";

            if (String.IsNullOrEmpty(IDTextBox.Text))
            {
                MetroMessageBox.Show(this, "ID를 입력하여 주세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                IDTextBox.Focus();
                return;
            }
            else if (String.IsNullOrEmpty(PWTextBox.Text))
            {
                MetroMessageBox.Show(this, "Password를 입력하여 주세요.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PWTextBox.Focus();
                return;
            }

            MySqlConnection conn = new MySqlConnection(strconn);
            MySqlCommand    cmd  = new MySqlCommand();

            try
            {
                conn.Open();
                string strlogincheckQ = "select * from shop where sid = '" + IDTextBox.Text + "'";

                cmd.Connection  = conn;
                cmd.CommandText = strlogincheckQ;

                MySqlDataReader rdr = cmd.ExecuteReader();

                if (!rdr.HasRows)
                {
                    var Msgresult = MetroMessageBox.Show(this, "등록되지 않은 가맹점입니다.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (Msgresult == DialogResult.OK)
                    {
                        IDTextBox.Focus();
                    }
                }

                if (rdr.Read())
                {
                    if (rdr["spw"].ToString() == PWTextBox.Text)
                    {
                        var Msgresult = MetroMessageBox.Show(this, "성공", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (Msgresult == DialogResult.OK)
                        {
                            shopForm shopfrm = new shopForm();
                            //shopfrm.Text = rdr["sname"].ToString();
                            shopfrm.Show();
                            Program.ac.MainForm = shopfrm;
                            subposForm subposfrm = new subposForm();
                            subposfrm.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        var Msgresult = MetroMessageBox.Show(this, "아이디와 패스워드가 일치하지 않습니다.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (Msgresult == DialogResult.OK)
                        {
                            IDTextBox.Focus();
                        }
                    }
                }
                rdr.Dispose();
                rdr.Close();
            }
            catch (Exception E)
            {
                MetroMessageBox.Show(this, "데이터 베이스 오류 :\n" + E.Message + "\n" + E.StackTrace);
            }
            finally
            {
                cmd.Dispose();
                conn.Dispose();
                conn.Close();
            }
            return;
        }
 private void ClearTextBoxes()
 {
     IDTextBox.Clear();
     NameTextBox.Clear();
     DescriptionTextBox.Clear();
 }
Beispiel #20
0
        private void AddNewProduct_Click(object sender, EventArgs e)
        {
            if (IDTextBox.Text == "")
            {
                MessageBox.Show("ID can't be blank!!!", "Blank ID");
            }
            else if (NameTextBox.Text == "")
            {
                MessageBox.Show("Name can't be blank!!!", "Blank Name");
            }
            else if (UnitListComboBox.Text == "")
            {
                MessageBox.Show("Unit can't be blank!!!", "Blank Quantity");
            }
            else if (QuantityTextBox.Text == "")
            {
                MessageBox.Show("Quantity can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyTextBox.Text == "")
            {
                MessageBox.Show("Money can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyUnitComboBox.Text == "")
            {
                MessageBox.Show("Money Unit can't be blank!!!", "Blank Quantity");
            }
            else
            {
                int size   = -1;
                int result = -1;
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("id", typeof(int));
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("unit", typeof(string));
                    dt.Columns.Add("quantity", typeof(int));
                    dt.Columns.Add("money", typeof(int));
                    dt.Columns.Add("moneyunit", typeof(string));
                    size = 0;

                    DBUtils.OpenConnection(conn);
                    string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID='" + IDTextBox.Text + "' or ProductName='" + NameTextBox.Text.ToUpper() + "';";

                    SqlCommand    command    = new SqlCommand(cmd, conn);
                    SqlDataReader dataReader = command.ExecuteReader();

                    Product temp = new Product();
                    while (dataReader.Read())
                    {
                        temp.setID((int)dataReader.GetValue(0));
                        temp.setName(dataReader.GetValue(1).ToString().ToUpper());
                        temp.setUnit(dataReader.GetValue(2).ToString());
                        temp.setQuantity((int)dataReader.GetValue(3));
                        temp.setMoney((int)dataReader.GetValue(4));
                        temp.setMoneyunit(dataReader.GetValue(5).ToString());

                        if (temp.getID() == Int32.Parse(IDTextBox.Text) | (temp.getName().ToUpper().CompareTo(NameTextBox.Text.ToUpper()) == 0))
                        {
                            dt.Rows.Add(temp.getID(), temp.getName().ToUpper(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());
                            Console.WriteLine(dt.Rows[size].Field <int>(0) + "\t" + dt.Rows[size].Field <string>(1) + "\t"
                                              + dt.Rows[size].Field <string>(2) + "\t" + dt.Rows[size].Field <int>(3) + "\t"
                                              + dt.Rows[size].Field <int>(4) + "\t" + dt.Rows[size].Field <string>(5));
                            Console.WriteLine("BYID - > size:" + size);
                            size++;
                        }
                    }
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    if (size == 0)
                    {
                        string Query = "insert into StockManagementSystemDatabase.dbo.Product_Cards_Table(ProductID,ProductName,ProductUnit,ProductQuantity, ProductMoney, ProductMoneyUnit) " +
                                       "values('" + this.IDTextBox.Text + "','" + this.NameTextBox.Text.ToUpper() + "','" + this.UnitListComboBox.Text + "','" + this.QuantityTextBox.Text +
                                       "','" + this.MoneyTextBox.Text + "','" + this.MoneyUnitComboBox.Text + "');";

                        SqlCommand MyCommand = new SqlCommand(Query, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand.ExecuteNonQuery();
                        MessageBox.Show("Save product", "SUCCESS INSERT");

                        //FillDataGridView();

                        cardTable.Rows.Add(this.IDTextBox.Text, this.NameTextBox.Text.ToUpper(), this.UnitListComboBox.Text, this.QuantityTextBox.Text, this.MoneyTextBox.Text, this.MoneyUnitComboBox.Text);
                        DataGridView_Products.DataSource = cardTable;
                        DataGridView_Products.Refresh();


                        string Query2 = "insert into StockManagementSystemDatabase.dbo.Move_Table(MoveProductID,MoveType,MoveDate,MoveQuantity,MoveQuantityUnit) " +
                                        "values('" + this.IDTextBox.Text + "','entry','" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + this.QuantityTextBox.Text + "','" + this.UnitListComboBox.Text + "');";

                        SqlCommand MyCommand2 = new SqlCommand(Query2, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand2.ExecuteNonQuery();
                        DBUtils.CloseConnection(conn);


                        result = 1;
                    }
                    else
                    {
                        result = 2;
                    }
                }
                catch
                {
                    if (result == 2)
                    {
                        MessageBox.Show("Same Product", "WARNING");
                        IDTextBox.Clear();
                        NameTextBox.Clear();
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("NOLUYO!");
                    }
                }
                finally
                {
                    DBUtils.CloseConnection(conn);
                    DataGridView_Products.DataSource = cardTable;
                    DataGridView_Products.Refresh();
                    FillDataGridView();

                    IDTextBox.Clear();
                    NameTextBox.Clear();
                    UnitListComboBox.Text = "";
                    QuantityTextBox.Clear();
                    MoneyTextBox.Clear();
                    MoneyUnitComboBox.Text = "";
                }
            }
        }
Beispiel #21
0
        private void UpdateThisButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id", typeof(int));
                dt.Columns.Add("name", typeof(string));
                dt.Columns.Add("unit", typeof(string));
                dt.Columns.Add("quantity", typeof(int));
                dt.Columns.Add("money", typeof(int));
                dt.Columns.Add("moneyunit", typeof(string));

                DBUtils.OpenConnection(conn);
                string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID=" + IDTextBox.Text + ";";

                SqlCommand    command    = new SqlCommand(cmd, conn);
                SqlDataReader dataReader = command.ExecuteReader();

                if (!dataReader.Read())
                {
                    MessageBox.Show("This product already exists.", "EXIST");
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);
                }
                else
                {
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    string Query = "update StockManagementSystemDatabase.dbo.Product_Cards_Table set ProductID='" + IDTextBox.Text
                                   + "',ProductName='" + NameTextBox.Text + "',ProductUnit='" + UnitListComboBox.Text + "',ProductQuantity='" + QuantityTextBox.Text
                                   + "',ProductMoney='" + this.MoneyTextBox.Text + "',ProductMoneyUnit='" + this.MoneyUnitComboBox.Text + "' WHERE ProductID=@ProductID;";

                    SqlCommand MyCommand = new SqlCommand(Query, conn);

                    MyCommand.Parameters.AddWithValue("@ProductID", IDTextBox.Text.ToString());

                    DBUtils.OpenConnection(conn);
                    MyCommand.ExecuteNonQuery();
                    MessageBox.Show("Update product", "SUCCESS UPDATE");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(conn);
                FillDataGridView();

                InformationTextBox.Visible = false;
                AddNewProduct.Visible      = true;

                IDTextBox.Enabled   = true;
                NameTextBox.Enabled = true;

                IDTextBox.Clear();
                NameTextBox.Clear();
                UnitListComboBox.Text = "";
                QuantityTextBox.Clear();
                MoneyTextBox.Clear();
                MoneyUnitComboBox.Text = "";
            }
        }
Beispiel #22
0
 private void reset()
 {
     bindingDateGridView();
     IDTextBox.Clear();
     //// CusromerNameTextBox.Clear();
 }
Beispiel #23
0
 private void AddID_Button_Click(object sender, EventArgs e)
 {
     airport_nodes.AddNode(IDTextBox.Text);
     IDTextBox.Clear();
 }
 public void Limpiar()
 {
     IDTextBox.Clear();
     NombreTextBox.Clear();
     LimiteTextBox.Clear();
 }