Exemplo n.º 1
0
        public static void Write(int sourcePlayerID, string action)
        {
            logfile myLog = new logfile();

            myLog.sourceplayer = sourcePlayerID;
            myLog.logdate      = DateTime.Now;
            myLog.action       = action;

            myLog.Save();
        }
        private void log()
        {
            if (TextBox1.Text == "" || TextBox2.Text == "")
            {
                MessageBox.Show("Please Complete the data");
            }
            else
            {
                MySqlConnection myconn = new MySqlConnection(connection);

                MySqlDataReader r;

                try
                {
                    myconn.Open();

                    MySqlCommand selectcomm = new MySqlCommand("employee", myconn);
                    selectcomm.CommandType = CommandType.StoredProcedure;

                    selectcomm.Parameters.AddWithValue("@k", "login");
                    selectcomm.Parameters.AddWithValue("@Id_par1", 0);
                    selectcomm.Parameters.AddWithValue("@Name_par2", "None");
                    selectcomm.Parameters.AddWithValue("@Job_par3", "None");
                    selectcomm.Parameters.AddWithValue("@Phone_par4", 0);
                    selectcomm.Parameters.AddWithValue("@Address_par5", "None");
                    selectcomm.Parameters.AddWithValue("@User_par6", TextBox1.Text);
                    selectcomm.Parameters.AddWithValue("@Pass_par7", TextBox2.Text);
                    selectcomm.Parameters.AddWithValue("@Salary_par8", 0);
                    selectcomm.Parameters.AddWithValue("@Shift_par9", 0);

                    user = TextBox1.Text;

                    MySqlDataAdapter adapter = new MySqlDataAdapter(selectcomm);

                    DataTable datatb = new DataTable();

                    adapter.Fill(datatb);

                    if (datatb.Rows.Count == 1)
                    {
                        r = selectcomm.ExecuteReader();

                        r.Read();

                        if (r.GetValue(2).ToString() == "Casher")
                        {
                            Form1 dh = new Form1();
                            dh.Show();
                            this.Hide();
                        }
                        else if (r.GetValue(2).ToString() == "Admin")
                        {
                            adminHome ad = new adminHome();
                            ad.Show();
                            this.Hide();
                        }

                        logfile log    = new logfile();
                        bool    result = log.logfilee("select user,pass,Job from employee where user = user_par6 and pass = pass_par7");
                    }
                    else
                    {
                        MessageBox.Show("Username or password incorrect");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    myconn.Close();
                }
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs = null;
                StreamReader sr = null;

                try
                {
                    fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                    sr = new StreamReader(fs);
                    //   String s;
                    // s = sr.ReadLine();
                    string bankaccount;
                    bankaccount = sr.ReadLine();
                    while (bankaccount != null)
                    {
                        //   s = sr.ReadLine();
                        //   listBox1.Items.Add(s);
                        string start, end, nrdeposit, useraccount, useramount, logid;
                        //logid = sr.ReadLine();
                        //  s = sr.ReadLine();
                        bankaccount = sr.ReadLine();
                        start       = sr.ReadLine();
                        end         = sr.ReadLine();
                        // nrdeposit = sr.ReadLine();
                        useraccount = sr.ReadLine();
                        nrdeposit   = sr.ReadLine();
                        useramount  = sr.ReadLine();
                        // listBox1.Items.Add(s);
                        // foreach(ListBox items in listBox1.Items)
                        //  label1.Text = s;
                        //  s = sr.ReadLine();
                        logfile temp = new logfile(bankaccount, start, end, nrdeposit, useraccount, useramount);
                        mylog.Add(temp);
                        bankaccount = sr.ReadLine();
                        //bankaccount = sr.ReadLine();
                        // s = sr.ReadLine();
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show("something went wrong, IOException was thrown");
                }
                finally
                {
                    if (sr != null)
                    {
                        sr.Close();
                    }
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
                MessageBox.Show("*************loading is done*********************");
            }
            else
            {
                MessageBox.Show("there was an error opening the windows");
            }


            foreach (var v in mylog)
            {
                int nrAdded = LogData.savelog((v.BankAccountID), v.StartDate, v.EndDate, v.NrOfDeposit, v.UserAccount, v.amount);
                if (nrAdded > 0)
                {
                    MessageBox.Show("successfully added to the database");
                }
                else
                {
                    MessageBox.Show("you made an error please try again");
                }
            }
        }