Example #1
0
 private void btnsua_Click(object sender, EventArgs e)
 {
     Txtname.Enabled     = true;
     txtDiachi.Enabled   = true;
     txtemal.Enabled     = true;
     txtSdt.Enabled      = true;
     BtnLuuInf.Enabled   = true;
     radioNam.Enabled    = true;
     radioNu.Enabled     = true;
     updateImage.Visible = true;
     Txtname.Focus();
 }
Example #2
0
 void clean()
 {
     Txtid.Text = "";
     Txtname.Text = "";
     Textsur.Text = "";
     TxtJob.Text = "";
     MtbSalary.Text = "";
     Cmbcity.Text = "";
     RadioSingle.Checked = false;
     RadioMarried.Checked = false;
     Txtname.Focus();
 }
Example #3
0
        private void Txtname_KeyDown(object sender, KeyEventArgs e)
        {
            Regex name = new Regex("^[A-Z][a-zA-Z]*$");

            if (e.KeyCode == Keys.Enter)
            {
                if (Txtname.Text != "")
                {
                    if (name.IsMatch(Txtname.Text))
                    {
                        dtbdob.Focus();
                    }
                    else
                    {
                        Console.WriteLine("INVALID NAME");
                        Txtname.Focus();
                    }
                }
                else
                {
                    Console.WriteLine(" NAME CANNOT BE EMPTY");
                    Txtname.Focus();
                }
            }
            else if (e.KeyCode == Keys.Tab)
            {
                if (Txtname.Text != "")
                {
                    if (name.IsMatch(Txtname.Text))
                    {
                        dtbdob.Focus();
                    }
                    else
                    {
                        Console.WriteLine("INVALID NAME");
                        Txtname.Focus();
                    }
                }
                else
                {
                    Console.WriteLine(" NAME CANNOT BE EMPTY");
                    Txtname.Focus();
                }
            }
            else
            {
                Txtname.Focus();
            }
        }
Example #4
0
        //验证是否为空
        private bool ValidateInput()
        {
            bool isOk = true;

            if (TxtID.Text == "")
            {
                TxtID.BackColor = Color.Red;
                TxtID.Focus();
                isOk = false;
            }
            if (Txtname.Text == "")
            {
                Txtname.BackColor = Color.Red;
                Txtname.Focus();
                isOk = false;
            }
            if (Txtpwd.Text == "")
            {
                Txtpwd.BackColor = Color.Red;
                Txtpwd.Focus();
                isOk = false;
            }
            if (txtAddress.Text == "")
            {
                txtAddress.BackColor = Color.Red;
                txtAddress.Focus();
                isOk = false;
            }
            if (TxtpaperID.Text == "")
            {
                TxtpaperID.BackColor = Color.Red;
                TxtpaperID.Focus();
                isOk = false;
            }
            if (TxtcontactTel.Text == "")
            {
                TxtcontactTel.BackColor = Color.Red;
                TxtcontactTel.Focus();
                isOk = false;
            }

            return(isOk);  //返回结果
        }
Example #5
0
        private void btnsubmit_Click_1(object sender, RoutedEventArgs e)
        {
            if (Txtname.Text == "")
            {
                MessageBox.Show("Fill Name !");
                Txtname.Focus();
            }
            else if (Txtstock.Text == "")
            {
                MessageBox.Show("Fill Stock !");
                Txtstock.Focus();
            }
            else if (Txtprice.Text == "")
            {
                MessageBox.Show("Fill Price !");
                Txtprice.Focus();
            }
            else
            {
                int Stock = Convert.ToInt32(Txtstock.Text);
                int Price = Convert.ToInt32(Txtprice.Text);

                var supplier = myContext.Suppliers.Where(p => p.Id == supplierid).FirstOrDefault();
                var item     = myContext.Items.Where(i => i.Name == Txtname.Text).FirstOrDefault();
                if (Txtname.Text != "")
                {
                    if (item != null)
                    {
                        var vqty   = item.Stock;
                        var vprice = item.Price;
                        if (Txtprice.Text == vqty.ToString())
                        {
                            laststock  = Stock + vqty;
                            item.Stock = Convert.ToInt32(laststock);
                            var result2 = myContext.SaveChanges();
                            if (result2 > 0)
                            {
                                MessageBox.Show("Stock has been inserted !");
                            }
                            else
                            {
                                MessageBox.Show("Stock can't update !");
                            }
                        }
                        else
                        {
                            var pushItem = new Item(Txtname.Text, Stock, Price, supplier);
                            myContext.Items.Add(pushItem);
                            var result = myContext.SaveChanges();
                            if (result > 0)
                            {
                                MessageBox.Show("row has been inserted");

                                GridItem.ItemsSource = myContext.Items.ToList();
                            }
                        }
                        GridItem.ItemsSource = myContext.Items.ToList();
                    }
                    else
                    {
                        var pushItem = new Item(Txtname.Text, Stock, Price, supplier);
                        myContext.Items.Add(pushItem);
                        var result = myContext.SaveChanges();
                        if (result > 0)
                        {
                            MessageBox.Show("row has been inserted");

                            Txtid.Text           = "";
                            Txtname.Text         = "";
                            Txtstock.Text        = "";
                            Txtprice.Text        = "";
                            GridItem.ItemsSource = myContext.Items.ToList();
                        }
                    }
                    GridItem.ItemsSource = myContext.Items.ToList();
                    Showdata();
                }
            }
        }