Beispiel #1
0
        private void bt_them_Click(object sender, EventArgs e)
        {
            if (txtMaCa.Text != "" && txtTenCa.Text != "")
            {
                DTO_Ca ca = new DTO_Ca(txtMaCa.Text, txtTenCa.Text);

                if (busYC6.insertCa(ca))
                {
                    MessageBox.Show("Thêm thành công");
                    datagv_ca.DataSource = busYC6.getCa();

                    txtMaCa.Text     = "";
                    txtTenCa.Text    = "";
                    txtMaCa.ReadOnly = false;
                }
                else
                {
                    MessageBox.Show("LỖI: Thêm không thành công !");
                }
            }
            else
            {
                MessageBox.Show("Xin hãy nhập đầy đủ các trường");
            }
        }
Beispiel #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            DTO_Ca ca = new DTO_Ca();

            //verified infor
            if (txtTenCa.Text == "")
            {
                MessageBox.Show("Thêm thất bại, tên ca còn trống");
                return;
            }
            //get infor to object
            ca.TenCa = txtTenCa.Text;

            DialogResult resultDialog = MessageBox.Show("Bạn có muốn thêm dữ liệu ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultDialog == DialogResult.Yes)
            {
                bool InsertState = BUS_Ca.InsertCa(ca);
                if (InsertState)
                {
                    dgvTableShow.DataSource = BUS_Ca.GetDataTable();
                    MessageBox.Show("Thêm thành công");
                }
                else
                {
                    MessageBox.Show("Thêm thất bại, thử lại");
                }
            }
            else
            {
                return;
            }
        }
Beispiel #3
0
        private void bt_sua_Click(object sender, EventArgs e)
        {
            if (txtTenCa.Text != "")
            {
                DTO_Ca ca = new DTO_Ca(txtMaCa.Text, txtTenCa.Text);

                if (busYC6.editCa(ca))
                {
                    MessageBox.Show("Sửa thành công");
                    datagv_ca.DataSource = busYC6.getCa();

                    txtMaCa.Text     = "";
                    txtTenCa.Text    = "";
                    txtMaCa.ReadOnly = false;
                }
                else
                {
                    MessageBox.Show("LỖI: Sửa không thành công !");
                }
            }
            else
            {
                MessageBox.Show("Vui lòng không để trống các trường");
            }
        }
Beispiel #4
0
        private void InsertCa()
        {
            DTO_Ca ca = new DTO_Ca();

            //verified infor
            if (txtTenCa.Text == "")
            {
                MessageBox.Show("Tên ca còn trống. Vui lòng nhập lại.");
                txtTenCa.Focus();
                return;
            }
            //get infor to object
            ca.TenCa = txtTenCa.Text;

            DialogResult resultDialog = MessageBox.Show("Bạn có muốn lưu ca này lại không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultDialog == DialogResult.Yes)
            {
                bool InsertState = BUS_Ca.InsertCa(ca);
                if (InsertState)
                {
                    dgvTableShow.DataSource = BUS_Ca.GetDataTable();
                    SetDisplay(DISPLAY.HOME);
                    MessageBox.Show("Thêm thành công");
                }
                else
                {
                    MessageBox.Show("Thêm thất bại, thử lại");
                }
            }
            else
            {
                return;
            }
        }
Beispiel #5
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            int rowSelect = -1;

            rowSelect = dgvTableShow.CurrentCell.RowIndex;
            //rowSelect = dgvTableShow.GetCellCount(DataGridViewElementStates.Selected);
            DTO_Ca ca = new DTO_Ca();

            ca.MaCa = Int32.Parse(dgvTableShow["MaCa", rowSelect].Value.ToString());
            DialogResult resultDialog = MessageBox.Show("Bạn có muốn xóa ca này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultDialog == DialogResult.Yes)
            {
                bool InsertState = BUS_Ca.DeleteCa(ca);
                if (InsertState)
                {
                    dgvTableShow.DataSource = BUS_Ca.GetDataTable();
                    SetDisplay(DISPLAY.HOME);
                    MessageBox.Show("Xóa thành công");
                }
                else
                {
                    MessageBox.Show("Xóa thất bại, thử lại");
                }
            }
            else
            {
                return;
            }
        }
Beispiel #6
0
        public bool insertCa(DTO_Ca ca)
        {
            // Ket noi
            SQLiteConnection connect = getConnection();

            connect.Open();

            try
            {
                // Query string
                string SQL = string.Format("INSERT INTO CA(MACA, TENCA) VALUES ('{0}', '{1}')", ca.MaCa, ca.TenCa);

                SQLiteCommand cmd = new SQLiteCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e) { }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
Beispiel #7
0
        public bool editCa(DTO_Ca ca)
        {
            // Ket noi
            SQLiteConnection connect = getConnection();

            connect.Open();

            try
            {
                // Query string
                string SQL = string.Format("UPDATE CA SET TENCA = '{0}' WHERE MACA = '{1}';", ca.TenCa, ca.MaCa);

                SQLiteCommand cmd = new SQLiteCommand(SQL, connect);

                // Query và kiểm tra
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }
            catch (Exception e) { }
            finally
            {
                // Dong ket noi
                connect.Close();
            }

            return(false);
        }
 public bool editCa(DTO_Ca ca)
 {
     if ((dalCa.searchCA(ca.MaCa)) != null)
     {
         return(false);
     }
     return(dalCa.editCa(ca));
 }
        public static bool UpdateCa(DTO_Ca ca)
        {
            string sTruyVan = string.Format("Update Ca set TenCa=N'{0}' where MaCa='{1}'", ca.TenCa, ca.MaCa);

            try
            {
                int state = DatabaseHelper.ExcuteSql(sTruyVan);
                if (state > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Beispiel #10
0
        public static bool DeleteCa(DTO_Ca ca)
        {
            string sTruyVan = string.Format("Delete from Ca where MaCa = '{0}'", ca.MaCa);

            try
            {
                int state = DatabaseHelper.ExcuteSql(sTruyVan);
                if (state > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Beispiel #11
0
        public static bool InsertCa(DTO_Ca ca)
        {
            string sTruyVan = string.Format("Insert into Ca(TenCa) values (N'{0}')", ca.TenCa);

            try
            {
                int state = DatabaseHelper.ExcuteSql(sTruyVan);
                if (state > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(false);
        }
Beispiel #12
0
        private void UpdateCa()
        {
            int rowSelect = -1;

            rowSelect = dgvTableShow.CurrentCell.RowIndex;
            DTO_Ca ca = new DTO_Ca();

            //verified infor
            if (txtTenCa.Text == "")
            {
                MessageBox.Show("Tên ca còn trống. Vui lòng nhập lại.");
                return;
            }
            //get new object
            ca.TenCa = txtTenCa.Text;
            ca.MaCa  = Int32.Parse(dgvTableShow["MaCa", rowSelect].Value.ToString());
            DialogResult resultDialog = MessageBox.Show("Bạn có muốn sửa dữ liệu ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultDialog == DialogResult.Yes)
            {
                bool UpdateState = BUS_Ca.UpdateCa(ca);
                if (UpdateState)
                {
                    dgvTableShow.DataSource = BUS_Ca.GetDataTable();
                    SetDisplay(DISPLAY.HOME);
                    MessageBox.Show("Cập nhật thành công");
                }
                else
                {
                    MessageBox.Show("Cập nhật thất bại");
                }
            }
            else
            {
                return;
            }
        }
 public bool insertCa(DTO_Ca ca)
 {
     return(dalCa.insertCa(ca));
 }
Beispiel #14
0
 public static bool DeleteCa(DTO_Ca ca)
 {
     return(DAO_Ca.DeleteCa(ca));
 }
Beispiel #15
0
 public static bool UpdateCa(DTO_Ca ca)
 {
     return(DAO_Ca.UpdateCa(ca));
 }
Beispiel #16
0
 public static bool InsertCa(DTO_Ca ca)
 {
     return(DAO_Ca.InsertCa(ca));
 }