Пример #1
0
 //Type session
 public static StoreInfo sharedStoreInfo()
 {
     if (storeInfo == null)
     {
         storeInfo = new StoreInfo();
     }
     return storeInfo;
 }
Пример #2
0
        public Main_Form()
        {
            InitializeComponent();
            StoreInfo.sharedStoreInfo().main = this;

            //show username
            username_label.Text = StoreInfo.sharedStoreInfo().Global_Username;

            //Cage manager
            RefreshNameCageList();

            //Animal Manager
            RefreshNameAnimalList();
            CheckInventory();
        }
Пример #3
0
        public void RefreshList()
        {
            AnimalList = new List <Animal>();
            DataSet data = StoreInfo.sharedStoreInfo().LoadTable("animalrecords_tb");

            foreach (DataTable table in data.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    int    id   = Convert.ToInt32(row.ItemArray[0].ToString());
                    string name = row.ItemArray[1].ToString();

                    Animal animal = new Animal(id, name);
                    AnimalList.Add(animal);
                }
            }
        }
Пример #4
0
        private void login_btn_Click(object sender, EventArgs e)
        {
            string user = this.username_input.Text;
            string pass = this.password_input.Text;


            if (StoreInfo.sharedStoreInfo().CheckLogin(user, pass))
            {
                this.Hide();
                Main_Form mf = new Main_Form();
                mf.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Login failed!!!!\nYour username and password are incorrect");
            }
        }
Пример #5
0
        private string LoadAnimalName(int ID)
        {
            string mock = null;

            DataSet ds = StoreInfo.sharedStoreInfo().LoadTable("animalrecords_tb");

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (Convert.ToInt32(row.ItemArray[0]) == ID)
                    {
                        mock = row.ItemArray[1].ToString();
                    }
                }
            }
            return(mock);
        }
Пример #6
0
        public void CheckLogin(string username, string password)
        {
            MySqlConnection connection = new MySqlConnection(myConnectionString);

            connection.Open();
            try
            {
                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = "SELECT * FROM user";
                MySqlDataAdapter adap = new MySqlDataAdapter(cmd);
                DataSet          ds   = new DataSet();
                adap.Fill(ds);

                foreach (DataTable table in ds.Tables)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        if (username == row.ItemArray[0].ToString() && password == row.ItemArray[1].ToString())
                        {
                            StoreInfo.sharedStoreInfo().Global_Username    = username;
                            StoreInfo.sharedStoreInfo().Global_Password    = password;
                            StoreInfo.sharedStoreInfo().Global_LoginStatus = true;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
Пример #7
0
 private void add_new_animal_btn_Click(object sender, EventArgs e)
 {
     animal.Update();
     StoreInfo.sharedStoreInfo().main.RefreshNameAnimalList();
     this.Close();
 }