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
        public void ShowList(string query)
        {
            DataTable dt = new DataTable();

            db.readDatathroughAdapter(query, dt);
            dgvPhongBan.DataSource = dt;
        }
Ejemplo n.º 3
0
        private void uctXoaNV_Load(object sender, EventArgs e)
        {
            DataTable dttbLoad = new DataTable();
            string    query    = "Select * From NhanVien";

            db.readDatathroughAdapter(query, dttbLoad);
            dgvXoaNV.DataSource = dttbLoad;
        }
Ejemplo n.º 4
0
        private void uctTrinhDo_Load(object sender, EventArgs e)
        {
            DataTable dttbLoad = new DataTable();
            string    query    = "Select * From TrinhDo";

            db.readDatathroughAdapter(query, dttbLoad);
            dgvTrinhDo.DataSource = dttbLoad;
        }
Ejemplo n.º 5
0
        public void search()
        {
            dtObject.Clear();
            string search = "select * from Object where DisplayName = N'" + tbNameB.Text + "'";

            vatTu.readDatathroughAdapter(search, dtObject);
            if (dtObject.Rows.Count == 0)
            {
                MessageBox.Show("Vui lòng kiểm tra lại tên hiển thị.", "Thông báo.");
            }
            else
            {
                //lấy thông tin nhân viên từ dtb
                cbbUnitB.Text     = dtObject.Rows[0]["IdUnit"].ToString();
                cbbSupplierB.Text = dtObject.Rows[0]["IdSupplier"].ToString();
            }
        }
        public void search()
        {
            string search = "select * from Customer where DisplayName = N'" + tbNameB.Text + "'";

            khachhang.readDatathroughAdapter(search, dtCus);
            if (dtCus.Rows.Count == 0)
            {
                MessageBox.Show("Vui lòng kiểm tra lại tên hiển thị.", "Thông báo.");
            }
            else
            {
                string date;
                //lấy thông tin nhân viên từ dtb
                tbAddressB.Text = dtCus.Rows[0]["Address"].ToString();
                tbPhoneB.Text   = dtCus.Rows[0]["ContactNum"].ToString();
                tbEmailB.Text   = dtCus.Rows[0]["Email"].ToString();
                tbInfoB.Text    = dtCus.Rows[0]["AddInfo"].ToString();
                date            = dtCus.Rows[0]["ContractDate"].ToString();
                dateB.Text      = date;
            }
        }
Ejemplo n.º 7
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.º 8
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            //ấn nút tìm kiếm để lấy thông tin lương theo mã
            string search = "select * from Luong where MaLuong = '" + tbWageID.Text + "'";

            nhanvien.readDatathroughAdapter(search, dtLuong);
            if (dtLuong.Rows.Count != 0 && tbDayEdit.Text == "" && tbWageEdit.Text == "")
            {
                MessageBox.Show("Tìm kiếm thành công!!", "Thông báo.");
                //lấy thông tin Lương từ dtb
                day  = dtLuong.Rows[0]["NgayCong"].ToString();
                wage = dtLuong.Rows[0]["LuongCB"].ToString();

                //hiện thông tin Lương
                tbDayEdit.Text  = day;
                tbWageEdit.Text = wage;
            }
            else
            {
                MessageBox.Show("Tìm kiếm thất bại. Vui lòng kiểm tra lại!!", "Lỗi.");
            }
        }
Ejemplo n.º 9
0
        private void buttonLogIn_Click(object sender, EventArgs e)
        {
            string username = txbUsername.Text;
            string password = txbPassword.Text;

            string query = "select * from users where Username = '******' and Password = '******'";

            dbAccess.readDatathroughAdapter(query, dtUsers);
            if (dtUsers.Rows.Count != 0)
            {
                quyen = dtUsers.Rows[0]["IdRole"].ToString();
                MessageBox.Show("Đăng nhập thành công!!!", "Thông báo.");
                tendangnhap = username;
                matkhaucu   = password;

                main.Show();
                Hide();
            }
            else
            {
                MessageBox.Show("Đăng nhập thất bại. Vui lòng kiểm tra lại!!!", "Lỗi.");
            }
        }
Ejemplo n.º 10
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();
        }