コード例 #1
0
ファイル: RegisterQL.cs プロジェクト: nguyenhuahuy24/doan1
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            string   user = textBoxUsername.Text;
            string   pass = textBoxPassword.Text;
            string   CV   = "QuanLy";
            Random   rd   = new Random();
            int      id   = rd.Next(200, 300);
            Nhanvien nv   = new Nhanvien();

            if (nv.insertQL(id))
            {
                if (nv.insertLogin(user, pass, CV, id))
                {
                    MessageBox.Show("Thêm Quản Lý thành Công", "Register Quản Lý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Thất Bại xem lại thông tin", "Register Quản Lý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Thất Bại xem lại thông tin", "Regiter Quản Lý", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: QuanLyLogin.cs プロジェクト: nguyenhuahuy24/doan1
        private void QuanLyLogin_Load(object sender, EventArgs e)
        {
            Nhanvien   nv      = new Nhanvien();
            SqlCommand command = new SqlCommand("SELECT * FROM TTNV as a, Login as b WHERE a.IdNhanVien = b.Id ");

            dataGridView1.ReadOnly   = true;
            dataGridView1.DataSource = nv.getLaoCong(command);
        }
コード例 #3
0
ファイル: QuanLyLogin.cs プロジェクト: nguyenhuahuy24/doan1
        public void fillGrid(SqlCommand command)
        {
            Nhanvien nhanvien = new Nhanvien();

            dataGridView1.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridView1.RowTemplate.Height = 40;
            dataGridView1.DataSource         = nhanvien.getAllTTKH(command);
            dataGridView1.AllowUserToAddRows = false;
        }
コード例 #4
0
        public void fillGrid(SqlCommand command)
        {
            Nhanvien nhanvien = new Nhanvien();

            dataGridViewManagerStudent.ReadOnly = true;
            DataGridViewImageColumn picCol = new DataGridViewImageColumn();

            dataGridViewManagerStudent.RowTemplate.Height = 100;
            dataGridViewManagerStudent.DataSource         = nhanvien.getAllTTKH(command);
            picCol             = (DataGridViewImageColumn)dataGridViewManagerStudent.Columns[7];
            picCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
            dataGridViewManagerStudent.AllowUserToAddRows = false;
        }
コード例 #5
0
ファイル: QuanLyLogin.cs プロジェクト: nguyenhuahuy24/doan1
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Nhanvien nv       = new Nhanvien();
         string   username = textBox1.Text;
         string   password = textBox2.Text;
         if (nv.updateLogin(username, password))
         {
             MessageBox.Show("Cập nhập thành công", " Cập Nhập Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("Thất Bại", " Cập Nhập Login", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message);
     }
 }
コード例 #6
0
 private void ButtonAdd_Click(object sender, EventArgs e)
 {
     if ((TextboxID.Text.Trim() == ""))
     {
         MessageBox.Show("Enter ID To ADD", " Thêm Lao CÔng", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         My_DB    db       = new My_DB();
         Nhanvien nhanvien = new Nhanvien();
         int      ca       = (int)ComboBoxCaDK.SelectedValue;
         string   CV       = "LaoCong";
         int      id       = Convert.ToInt32(TextboxID.Text);
         string   fname    = TextboxFirstName.Text;
         string   lname    = TextboxLastName.Text;
         DateTime bdate    = dateTimePickerLetan.Value;
         string   phone    = TextboxPhone.Text;
         string   adrs     = TextboxAddress.Text;
         string   UserName = TextBoxUSERNAME.Text;
         string   Password = TextBoxPASSWORD.Text;
         string   LBGT     = "Male";
         if (RadioButtonFemale.Checked)
         {
             LBGT = "Female";
         }
         MemoryStream   pic       = new MemoryStream();
         int            born_year = dateTimePickerLetan.Value.Year;
         int            this_year = DateTime.Now.Year;
         SqlDataAdapter adapter   = new SqlDataAdapter();
         DataTable      table     = new DataTable();
         SqlCommand     command   = new SqlCommand("Select * From TTNV WHERE @ID= IdNhanVien", db.GetConnection);
         command.Parameters.Add("@ID", SqlDbType.VarChar).Value = TextboxID.Text;
         adapter.SelectCommand = command;
         adapter.Fill(table);
         if ((table.Rows.Count) > 0)
         {
             MessageBox.Show("trung id", " nhap lai", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else if (((this_year - born_year) < 18) || ((this_year - born_year) > 50))
         {
             MessageBox.Show("Tuổi lao công từ 18 -> 50", " Birth Date error", MessageBoxButtons.OK, MessageBoxIcon.Error);;
         }
         else if (verif1())
         {
             pictureBox1.Image.Save(pic, pictureBox1.Image.RawFormat);
             if (nhanvien.insertNhanVien(id, fname, lname, bdate, LBGT, phone, adrs, pic, ca))
             {
                 if (nhanvien.insertLogin(UserName, Password, CV, id))
                 {
                     MessageBox.Show("Thành Công", " Thêm nhân viên", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
             else
             {
                 MessageBox.Show("Thất bại", "Thêm nhân viên", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Thiếu thông tin", " Thêm nhân viên", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: nguyenhuahuy24/doan1
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            Nhanvien nv = new Nhanvien();
            My_DB    db = new My_DB();

            db.openConnection();
            try
            {
                SqlCommand command = new SqlCommand("SELECT * FROM Login WHERE UserName = @User AND PassWord = @Pass ", db.GetConnection);
                command.Parameters.Add("@User", SqlDbType.VarChar).Value = TextBoxUser.Text;
                command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = TextBoxPassword.Text;

                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable      table   = new DataTable();
                adapter.SelectCommand = command;
                adapter.Fill(table);
                SqlCommand command2 = new SqlCommand("Select ChucVu From Login where UserName like '" + TextBoxUser.Text + "%'");
                DataTable  table2   = nv.getLaoCong(command2);
                string     ChucVu   = (string)table2.Rows[0]["ChucVu"];
                SqlCommand command3 = new SqlCommand("Select Id From Login where UserName like '" + TextBoxUser.Text + "%'");
                DataTable  table3   = nv.getLaoCong(command3);
                int        Id       = (int)table3.Rows[0]["Id"];
                if (ChucVu == "LaoCong   ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        LaoCong str = new LaoCong();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else if (ChucVu == "LeTan     ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        LeTan str = new LeTan();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else if (ChucVu == "QuanLy    ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        Quan_ly str = new Quan_ly();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Invalid Username or Password ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #8
0
        private void ButtonKT_Click_1(object sender, EventArgs e)
        {
            int id = Global.GlobalUserId;
            My_DB mydb = new My_DB();
            DemGio dg = new DemGio();
            DateTime GioBD;
            string fname;
            int ca;
            string HoTen;
            double luong = 0;
            Nhanvien nhanvien = new Nhanvien();
            DateTime gioKT = DateTime.Now;
            int tonggiolam;
            int tongphutlam;


            SqlDataAdapter adapter = new SqlDataAdapter();
            DataTable table = new DataTable();
            SqlCommand command = new SqlCommand("Select * From BaoCaoNgay WHERE @ID= Id", mydb.GetConnection);
            command.Parameters.Add("@ID", SqlDbType.VarChar).Value = id; ;
            adapter.SelectCommand = command;
            adapter.Fill(table);

            SqlCommand command4 = new SqlCommand("Select CaLamViec From TTNV WHERE IdNhanVien =" + id);
            DataTable table4 = nhanvien.getLaoCong(command4);
            ca = (int)table4.Rows[0]["CaLamViec"];

            SqlCommand command1 = new SqlCommand("Select Fname From TTNV WHERE IdNhanVien =" + id);
            DataTable table1 = nhanvien.getLaoCong(command1);
            fname = table1.Rows[0]["Fname"].ToString();

            

            SqlCommand command2 = new SqlCommand("Select GioBD From BaoCaoNgay WHERE Id =" + id);
            DataTable table2 = nhanvien.getLaoCong(command2);
            GioBD = (DateTime)table2.Rows[0]["GioBD"];
            try
            {
                if (table.Rows.Count > 0)
                {
                    if (gioKT.Hour < GioBD.Hour)
                    {
                        if (gioKT.Minute < GioBD.Minute)
                        {
                            tonggiolam = gioKT.Hour + 24 - GioBD.Hour - 1;
                            tongphutlam = gioKT.Minute + 60 - GioBD.Minute;
                        }
                        else
                        {
                            tonggiolam = gioKT.Hour + 24 - GioBD.Hour;
                            tongphutlam = gioKT.Minute - GioBD.Minute;

                        }
                    }
                    else
                    {
                        if (gioKT.Minute < GioBD.Minute)
                        {
                            tonggiolam = gioKT.Hour - GioBD.Hour - 1;
                            tongphutlam = gioKT.Minute + 60 - GioBD.Minute;
                        }
                        else
                        {
                            tonggiolam = gioKT.Hour - GioBD.Hour;
                            tongphutlam = gioKT.Minute - GioBD.Minute;

                        }
                    }
                    if (tonggiolam >= 8)
                    {
                        if (tonggiolam < 9)
                        {
                            luong = Math.Round(8 * 40000 + ((float)tongphutlam / 60) * 0, 0);

                        }
                        else if (tonggiolam >= 9)
                        {
                            luong = Math.Round(tonggiolam * 400000 + ((float)tongphutlam / 60) * 0, 0);


                        }
                    }
                    else
                    {
                        if (tonggiolam == 7 && tongphutlam >= 45)
                        {
                            luong = Math.Round(8 * 40000 + ((float)tongphutlam / 60) * 0, 0);
                        }
                        else
                        {
                            luong = Math.Round(8 * 40000 + ((float)tongphutlam / 60) * 0 - (8 - tonggiolam) * 80000, 0);
                        }
                    }
                    try
                    {
                        if (dg.updateBaoCaoNgay(id, fname, gioKT, tonggiolam, tongphutlam, luong))
                        {
                            dg.deleteBaoCao(id);
                            dg.updateBaoCaoThang(id, fname, gioKT, tonggiolam, tongphutlam, luong);
                            MessageBox.Show("Kết thúc giờ làm", " End", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Chưa bắt đầu", "Error Id", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Chưa Bắt đầu công việc", "Check-out", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else
                {
                    MessageBox.Show("Chưa Bắt đầu công việc", "Check-out", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                }
            }
            catch(Exception exp)
            {

            }
        }