Ejemplo n.º 1
0
 private void buttonA_Click(object sender, EventArgs e)
 {
     if (cbbIDA.Text == "0" || numberA.Text == "0" || cbbCusA.Text == "Chris")
     {
         MessageBox.Show("Vui lòng kiểm tra lại các thông tin nhập.", "Thông báo.");
     }
     else
     {
         string check = "select * from OUTPUT o1, OUTPUTINFO o2 where (o1.Id = o2.Id) and (o1.Id = '" + num1.Value + "')";
         xuat.readDatathroughAdapter(check, dtXuat);
         if (dtXuat.Rows.Count != 0)
         {
             MessageBox.Show("Vui lòng kiểm tra lại mã xuất.", "Thông báo.");
         }
         else
         {
             SqlCommand add1 = new SqlCommand("insert into OUTPUT(Id,OutputDate) values ('" + num1.Text + "','" + dateA.Value.ToString() + "')");
             SqlCommand add2 = new SqlCommand("insert into OUTPUTINFO(Id,IdInputInfo,IdCustomer,Count) values ('" + num1.Text + "','" + cbbIDA.Text
                                              + "','" + cbbCusA.SelectedValue + "','" + numberA.Text + "')");
             xuat.executeQuery(add2);
             xuat.executeQuery(add1);
             MessageBox.Show("Thêm đơn thành công.", "Thông báo.");
             clearData();
         }
     }
     loadData();
 }
Ejemplo n.º 2
0
 private void btXoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvTrinhDo.RowCount == 0)
         {
             btXoa.Enabled = false;
         }
         else if (XtraMessageBox.Show("Bạn có chắc chắn xóa dòng này không?", "Cảnh Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             // Chỉ mục hiện tại
             int    selectIndex = dgvTrinhDo.SelectedRows[0].Index;
             string MaTrinhDo   = Convert.ToString(dgvTrinhDo[0, selectIndex].Value);
             //query
             string     sql     = "DELETE FROM TrinhDo Where MaTrinhDo = '" + MaTrinhDo + "' ;";
             SqlCommand deteRow = new SqlCommand(sql);
             db.executeQuery(deteRow);
             //Remove khỏi datagird
             dgvTrinhDo.Rows.RemoveAt(selectIndex);
             //dgvXoaNV.DataSource = dttbLoad;
             this.RefeshList();
         }
     }
     catch (Exception)
     {
         XtraMessageBox.Show("Đã có lỗi xảy ra. Vui lòng thử lại !", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (cbbCateAdd.Text != "" && tbID.Text != "" && tbDayAdd.Text != "" && tbWageAdd.Text != "")
            {
                if (cbbCateAdd.Text == "Hop dong lao dong")
                {
                    wageID = "LuongHDLD" + tbID.Text;
                }
                else if (cbbCateAdd.Text == "Hop dong CTV")
                {
                    wageID = "LuongCTV" + tbID.Text;
                }

                day  = tbDayAdd.Text;
                wage = tbWageAdd.Text;

                MessageBox.Show("Thêm thành công. Vui lòng click vào bảng Lương bên dưới để cập nhật!!!", "Thông báo.");
                SqlCommand add = new SqlCommand("INSERT Luong values('" + wageID + "','" + day + "', '" + wage + "')");
                nhanvien.executeQuery(add);
            }
            else
            {
                MessageBox.Show("Thêm thất bại. Vui lòng kiểm tra lại!!!", "Lỗi.");
            }
        }
Ejemplo n.º 4
0
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     //Nut Xoa
     if (dgvPhongBan.Rows.Count == 0)
     {
         btnXoa.Enabled = false;
     }
     else
     {
         try
         {
             DialogResult confirm = XtraMessageBox.Show("Bạn có chắc chắn xóa dòng này không?", "Cảnh Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (confirm == DialogResult.Yes)
             {
                 int        selectIndex = dgvPhongBan.SelectedRows[0].Index;
                 string     MaPhongBan  = Convert.ToString(dgvPhongBan[0, selectIndex].Value);
                 string     sql         = "DELETE FROM PhongBan Where MaPhongBan = '" + MaPhongBan + "' ;";
                 SqlCommand deteleRow   = new SqlCommand(sql);
                 db.executeQuery(deteleRow);
                 //Remove khỏi datagird
                 dgvPhongBan.Rows.RemoveAt(selectIndex);
                 ShowList(queryAll);
             }
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show("Error : " + ex.ToString());
         }
     }
 }
Ejemplo n.º 5
0
 private void buttonA_Click(object sender, EventArgs e)
 {
     //thêm mới vật tư
     if (tbNameA.Text == "" || cbbUnitA.Text == "Kg" || cbbSupplierA.Text == "CompanyA")
     {
         MessageBox.Show("Vui lòng kiểm tra lại các thông tin nhập.", "Thông báo.");
     }
     else
     {
         SqlCommand add = new SqlCommand("insert into Object values ('" + tbNameA.Text + "','" + cbbUnitA.Text + "','" + cbbSupplierA.Text + "')");
         vatTu.executeQuery(add);
         MessageBox.Show("Thêm mới thành công.", "Thông báo.");
         clearData();
     }
     loadData();
 }
Ejemplo n.º 6
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     //cập nhật thông tin người dùng
     if (tbOldPass.Text != frmLogin.matkhaucu)
     {
         MessageBox.Show("Vui lòng kiểm tra lại mật khẩu cũ.", "Thông báo.");
     }
     else
     {
         if (tbNewPass.Text != tbNewPass2.Text)
         {
             MessageBox.Show("Vui lòng kiểm tra lại mật khẩu mới.", "Thông báo.");
         }
         else
         {
             if (tbOldPass.Text == tbNewPass.Text)
             {
                 MessageBox.Show("Mật khẩu mới phải khác mật khẩu cũ.", "Thông báo.");
             }
             else
             {
                 SqlCommand edit = new SqlCommand("update Users set Password = '******' where Username = '******'");
                 user.executeQuery(edit);
                 MessageBox.Show("Cập nhật mật khẩu thành công. Vui lòng đăng nhập lại.", "Thông báo.");
                 Hide();
                 frmLogin form = new frmLogin();
                 form.Show();
             }
         }
     }
 }
 private void buttonA_Click(object sender, EventArgs e)
 {
     //thêm mới khách hàng
     if (tbNameA.Text == "" || tbAddressA.Text == "" || tbPhoneA.Text == "" || tbEmailA.Text == "" || tbInfoA.Text == "" || dateA.Value == null)
     {
         MessageBox.Show("Vui lòng kiểm tra lại các thông tin nhập.", "Thông báo.");
     }
     else
     {
         SqlCommand add = new SqlCommand("insert into Customer values ('" + tbNameA.Text + "','" + tbAddressA.Text + "','" +
                                         tbPhoneA.Text + "','" + tbEmailA.Text + "','" + tbInfoA.Text + "','" + dateA.Value.ToString() + "')");
         khachhang.executeQuery(add);
         MessageBox.Show("Thêm mới thành công.", "Thông báo.");
         clearData();
     }
     loadData();
 }
Ejemplo n.º 8
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            int        dem        = 0;
            SqlCommand query_name = new SqlCommand("select DisplayName from Unit where DisplayName like N'" + tbNameA.Text + "'", AccessDataBase.connection);

            using (SqlDataReader reader = query_name.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    // Đọc kết quả
                    while (reader.Read())
                    {
                        Console.WriteLine("{0}", reader[0].ToString());
                        if (reader[0].ToString().Equals(tbNameA.Text))
                        {
                            dem = 1;
                        }
                    }
                }
            }
            if (dem == 1)
            {
                XtraMessageBox.Show("Đơn vị đo đã tồn tại.", "Thông báo.");
            }
            else
            {
                if (tbNameA.Text == "")
                {
                    MessageBox.Show("Vui lòng kiểm tra lại thông tin nhập.", "Thông báo.");
                }
                else
                {
                    //Thêm mới đơn vị đo
                    SqlCommand add = new SqlCommand("insert into Unit values('" + tbNameA.Text + "')");
                    unit.executeQuery(add);
                    MessageBox.Show("Thêm thành công.", "Thông báo.");
                }
            }
            loadData();
        }
Ejemplo n.º 9
0
 private void bt1_Click(object sender, EventArgs e)
 {
     if (dgvXoaNV.RowCount == 0)
     {
         bt1.Enabled = false;
     }
     else if (XtraMessageBox.Show("Bạn có chắc chắn xóa dòng này không?", "Cảnh Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         // Chỉ mục hiện tại
         int    selectIndex = dgvXoaNV.SelectedRows[0].Index;
         string MaNV        = Convert.ToString(dgvXoaNV[0, selectIndex].Value);
         //query
         string     sql     = "DELETE FROM NhanVien Where MaNV = '" + MaNV + "' ;";
         SqlCommand deteRow = new SqlCommand(sql);
         db.executeQuery(deteRow);
         //Remove khỏi datagird
         dgvXoaNV.Rows.RemoveAt(selectIndex);
         //dgvXoaNV.DataSource = dttbLoad;
         this.RefeshList();
     }
 }
Ejemplo n.º 10
0
        private void buttonSignUp_Click(object sender, EventArgs e)
        {
            string search = "select * from Users where Username = '******'";

            SqlCommand insert = new SqlCommand("insert into Users(DisplayName,Username,Password, IdRole) values('Guest','" + txbUsername.Text + "','" + txbPassword.Text + "', 3)");

            dbAccess.readDatathroughAdapter(search, dtUsers);
            if (dtUsers.Rows.Count == 0 && txbPasswordR.Text == txbPassword.Text)
            {
                dbAccess.executeQuery(insert);
                MessageBox.Show("Đăng ký thành công!!!", "Thông báo.");
                frmLogin login = new frmLogin();
                login.Show();
                Hide();
            }
            if (dtUsers.Rows.Count != 0)
            {
                MessageBox.Show("Đã tồn tại tên đăng nhập. Vui lòng kiểm tra lại!!!", "Lỗi.");
                dtUsers.Clear();
            }
        }
Ejemplo n.º 11
0
        private void buttonA_Click(object sender, EventArgs e)
        {
            DataTable d1 = new DataTable();
            DataTable d2 = new DataTable();
            DataTable d3 = new DataTable();

            //theo mã đơn hàng, nhập hàng theo yêu cầu
            //nếu mã đã có thì thêm vào InputInfo
            //nếu mã chưa có thì thêm vào Input + InputInfo
            if (num1.Text == "0" || cbbObjA.Text == "1" || numberA.Text == "0" || tbInpPriceA.Text == "0" || tbOutPriceA.Text == "0")
            {
                MessageBox.Show("Vui lòng kiểm tra lại các thông tin nhập.", "Thông báo.");
            }
            else
            {
                //nếu có mã nhập
                string check = "Select i1.Id " +
                               "from INPUT i1, INPUTINFO i2 " +
                               "where (i1.Id = i2.IdInput) and (i1.Id = '" + num1.Value + "')";
                nhap.readDatathroughAdapter(check, dtNhap);
                if (dtNhap.Rows.Count != 0)
                {
                    string check1 = "Select i1.Id, i2.IdInput, i2.IdObject " +
                                    "from INPUT i1, INPUTINFO i2 " +
                                    "where (i1.Id = i2.IdInput) and (i1.Id = '" + num1.Value + "') and (IdObject = '" + cbbObjA.Text + "')";
                    nhap.readDatathroughAdapter(check1, d1);
                    //nếu có vật tư
                    if (d1.Rows.Count != 0)
                    {
                        string check2 = "Select i1.Id, i2.IdInput, i2.IdObject, i2.InputPrice " +
                                        "from INPUT i1, INPUTINFO i2 " +
                                        "where (i1.Id = i2.IdInput) and (i1.Id = '" + num1.Value + "')" +
                                        "and (IdObject = '" + cbbObjA.Text + "') and (InputPrice = '" + tbInpPriceA.Text + "')";
                        nhap.readDatathroughAdapter(check2, d2);
                        //nếu có giá nhập -> kiêm tra tiếp
                        if (d2.Rows.Count != 0)
                        {
                            string check3 = "Select i1.Id, i2.IdInput, i2.IdObject, i2.InputPrice, i2.OutputPrice " +
                                            "from INPUT i1, INPUTINFO i2 " +
                                            "where (i1.Id = i2.IdInput) and (i1.Id = '" + num1.Value + "')" +
                                            "and (IdObject = '" + cbbObjA.Text + "') and (InputPrice = '" + tbInpPriceA.Text + "') and (OutputPrice = '" + tbOutPriceA.Text + "')";
                            nhap.readDatathroughAdapter(check3, d3);
                            //chưa có giá xuất -> thêm vật tư mới vào đơn hàng đã có
                            if (d3.Rows.Count == 0)
                            {
                                SqlCommand add32 = new SqlCommand("insert into INPUTINFO(IdObject,IdInput,Count,InputPrice,OutputPrice) values ('" + cbbObjA.Text + "','" + num1.Text + "','" + numberA.Text + "','" +
                                                                  tbInpPriceA.Text + "','" + tbOutPriceA.Text + "')");
                                nhap.executeQuery(add32);
                                MessageBox.Show("Thêm mới vật tư thành công.", "Thông báo.");
                                clearData();
                            }
                            //có giá xuất -> cộng dồn số lượng
                            {
                                SqlCommand add3 = new SqlCommand("update INPUTINFO set Count = Count + '" + numberA.Text + "' where (IdInput = '" + num1.Value + "') and (IdObject = '" + cbbObjA.Text
                                                                 + "') and (InputPrice = '" + tbInpPriceA.Text + "') and (OutputPrice = '" + tbOutPriceA.Text + "')");
                                nhap.executeQuery(add3);
                                MessageBox.Show("Cập nhật thành công.", "Thông báo.");
                                clearData();
                            }
                        }
                        //nếu chưa có giá nhập -> thêm mới vật tư vào đơn hàng đã có
                        else
                        {
                            SqlCommand add2 = new SqlCommand("insert into INPUTINFO(IdObject,IdInput,Count,InputPrice,OutputPrice) values ('" + cbbObjA.Text + "','" + num1.Text + "','" + numberA.Text + "','" +
                                                             tbInpPriceA.Text + "','" + tbOutPriceA.Text + "')");
                            nhap.executeQuery(add2);
                            MessageBox.Show("Thêm mới vật tư thành công.", "Thông báo.");
                            clearData();
                        }
                    }
                    //nếu chưa có vật tư -> thêm mới vật tư vào đơn hàng đã có
                    else
                    {
                        SqlCommand add1 = new SqlCommand("insert into INPUTINFO(IdObject,IdInput,Count,InputPrice,OutputPrice) values ('" + cbbObjA.Text + "','" + num1.Text + "','" + numberA.Text + "','" +
                                                         tbInpPriceA.Text + "','" + tbOutPriceA.Text + "')");
                        nhap.executeQuery(add1);
                        MessageBox.Show("Thêm mới vật tư thành công.", "Thông báo.");
                        clearData();
                    }
                }
                //nếu chưa có mã nhâp
                else
                {
                    SqlCommand add01 = new SqlCommand("insert into INPUTINFO(IdObject,IdInput,Count,InputPrice,OutputPrice) values ('" + cbbObjA.Text + "','" + num1.Text + "','" + numberA.Text + "','" +
                                                      tbInpPriceA.Text + "','" + tbOutPriceA.Text + "')");
                    SqlCommand add02 = new SqlCommand("insert into INPUT(Id,InputDate) values ('" + num1.Text + "','" + dateA.Value.ToString() + "')");
                    nhap.executeQuery(add02);
                    nhap.executeQuery(add01);
                    MessageBox.Show("Thêm đơn nhập mới thành công.", "Thông báo.");
                    clearData();
                }
            }
            loadData();
        }
Ejemplo n.º 12
0
        private void Button1_Click(object sender, EventArgs e)
        {
            AccessDataBase db = new AccessDataBase();

            db.createConn();
            string gioiTinh, maphongBan, maloaiHopDong, machucVu, maNhanVien, maLuong, maTrinhDo;

            //Mã nhân viên
            maNhanVien = "BA" + txbCMND.Text;


            //phòng ban
            if (comboBoxPhongBan.Text.Equals("Phòng Kỹ Thuật") == true)
            {
                maphongBan = "PB02";
            }
            else
            {
                maphongBan = "PB03";
            }

            //chức vụ

            if (comboBoxChuVu.Text.Equals("Ban Giám Đốc") == true)
            {
                machucVu = "GD";
            }
            else if (comboBoxChuVu.Text.Equals("Trưởng phòng") == true)
            {
                machucVu = "TP";
            }
            else
            {
                machucVu = "NV";
            }

            //Loại hợp đồng

            if (comboBoxLoaiHD.Text.Equals("Hợp đồng CTV") == true)
            {
                maloaiHopDong = "CTV";
            }
            else
            {
                maloaiHopDong = "HDLD";
            }

            //giới tính
            if (radioButtonNam.Checked == true)
            {
                gioiTinh = "Nam";
            }
            else
            {
                gioiTinh = "Nữ";
            }

            //trình độ
            if (comboBoxTrinhDo.Text.Equals("Manager") == true)
            {
                maTrinhDo = "1";
            }
            else if (comboBoxTrinhDo.Text.Equals("Development") == true)
            {
                maTrinhDo = "2";
            }
            else
            {
                maTrinhDo = "3";
            }
            if (txbhoTen.Text.Trim().Equals("") == true || txbLuong.Text.Trim().Equals("") == true || txbSDT.Text.Trim().Equals("") == true ||
                txbDiaChi.Text.Trim().Equals("") == true || txbDanToc.Text.Trim().Equals("") == true || txbCMND.Text.Trim().Equals("") == true ||
                comboBoxChuVu.Text.Trim().Equals("") == true || comboBoxLoaiHD.Text.Trim().Equals("") == true || comboBoxPhongBan.Text.Trim().Equals("") == true ||
                comboBoxTrinhDo.Text.Trim().Equals("") == true || gioiTinh.Equals("") == true)
            {
                XtraMessageBox.Show("Mời nhập đầy đủ thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int        dem        = 0;
                SqlCommand query_name = new SqlCommand("SELECT CMTND FROM NhanVien WHERE CMTND LIKE '" + txbCMND.Text + "'", AccessDataBase.connection);
                using (SqlDataReader reader = query_name.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        // Đọc kết quả
                        while (reader.Read())
                        {
                            Console.WriteLine("{0}", reader[0].ToString());
                            if (reader[0].ToString().Equals(txbCMND.Text))
                            {
                                dem = 1;
                            }
                        }
                    }
                }
                if (dem == 1)
                {
                    XtraMessageBox.Show("Nhân viên đã tồn tại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //lương
                    if (IsNumber(txbLuong.Text) == true && IsNumber(txbCMND.Text) == true && IsNumber(txbSDT.Text) == true
                        )
                    {
                        int luong = Convert.ToInt32(txbLuong.Text);
                        if (luong <= 1000000)
                        {
                            maLuong = "LuongCTV" + txbCMND.Text;
                        }
                        else
                        {
                            maLuong = "LuongHDLD" + txbCMND.Text;
                        }
                        //chạy lệnh update Lương
                        SqlCommand query0 = new SqlCommand("INSERT Luong values ('" + maLuong + "','1','" + txbLuong.Text + "')");
                        nhanvien.executeQuery(query0);
                        //chạy lệnh update nhân viên
                        SqlCommand query = new SqlCommand("INSERT NhanVien values('" + maNhanVien + "','" + StandardString(txbhoTen.Text) + "', '" + ngaySinh.Value.ToString() + "'," +
                                                          " '" + gioiTinh + "', '" + StandardString(txbDanToc.Text) + "', '" + txbCMND.Text + "','" + txbSDT.Text + "', '"
                                                          + txbDiaChi.Text + "', '" + maphongBan + "', '" + machucVu + "', '" + maloaiHopDong + "', '" + maTrinhDo + "', '" + maLuong + "')");
                        nhanvien.executeQuery(query);
                        XtraMessageBox.Show("Thêm mới nhân viên thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XtraMessageBox.Show("Thông tin nhập vào không đúng định dạng!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }