Пример #1
0
        private void btnThemThietBi_Click(object sender, EventArgs e)
        {
            //lay du lieu tu form
            string id      = txtID.Text;
            string ten     = txtTen.Text;
            float  dongia  = float.Parse(txtDonGia.Text);
            int    soluong = int.Parse(txtSoLuong.Text);

            //thao tac them
            CSVC_DTO csvc = new CSVC_DTO(id, ten, dongia, soluong);
            CSVC_BUS t    = new CSVC_BUS();

            if (!t.ThemCSVC(csvc))
            {
                MessageBox.Show("Thêm không thành công. Vui lòng thử lại!");
            }

            //hien thi lai danh sach
            dgvDSThietBi.DataSource = t.LoadCSVC();
            bingding();

            //them vao bao cao chi
            DateTime      ngay      = DateTime.Now.Date;
            Baocaochi_DTO bc        = new Baocaochi_DTO(ngay, "Thiet bi", float.Parse(txtDonGia.Text) * int.Parse(txtSoLuong.Text));
            Baocaochi_BUS baocaochi = new Baocaochi_BUS();

            baocaochi.ThemBaoCao(bc);
        }
Пример #2
0
        public bool CapNhatCSVC(CSVC_DTO csvc)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "UPDATE CSVC SET Ten = @Ten, Dongia = @Dongia, Soluong = @Soluong WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;

            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters.Add("@Ten", SqlDbType.NVarChar, 50);
            cmd.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd.Parameters.Add("@Soluong", SqlDbType.Int);

            cmd.Parameters["@Id"].Value      = csvc.Id;
            cmd.Parameters["@Ten"].Value     = csvc.Ten;
            cmd.Parameters["@Dongia"].Value  = csvc.Dongia;
            cmd.Parameters["@Soluong"].Value = csvc.Soluong;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
Пример #3
0
        public DataTable load_dgv(CSVC_DTO csvc)
        {
            string    query  = "SELECT t_phongvattu.ID,t_cosovatchat.Donvi,t_cosovatchat.Ten,t_phongvattu.Soluong FROM t_phongvattu,t_loaiphong,t_cosovatchat WHERE t_cosovatchat.ID = t_phongvattu.Idcosovatchat and t_loaiphong.IDLP = t_phongvattu.Idloaiphong and t_loaiphong.IDLP = N'" + csvc.Temp + "'";
            DataTable result = new DataTable();

            result = processdata.Instance.ExecuteQuery(query);
            return(result);
        }
Пример #4
0
        public bool them_vattu(CSVC_DTO csvc)
        {
            string query = "INSERT INTO t_phongvattu VALUES(N'" + csvc.Idloaiphong + "',N'" + csvc.Idcsvc + "',N'" + csvc.Soluong + "')";

            if (processdata.Instance.ExecuteNonQuery(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        public bool sua_vattu(CSVC_DTO csvc)
        {
            string query = "UPDATE t_phongvattu SET Idloaiphong =N'" + csvc.Idloaiphong + "',Idcosovatchat =N'" + csvc.Idcsvc + "',Soluong =N'" + csvc.Soluong + "' WHERE ID ='" + csvc.Id + "'";

            if (processdata.Instance.ExecuteNonQuery(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        public bool them_csvc(CSVC_DTO csvc)
        {
            string query = "INSERT INTO t_cosovatchat VALUES(N'" + csvc.Id + "',N'" + csvc.Name + "')";

            if (processdata.Instance.ExecuteNonQuery(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #7
0
        public bool sua_csvc(CSVC_DTO csvc)
        {
            string query = "UPDATE t_cosovatchat SET ID =N'" + csvc.Idloaiphong + "',Ten =N'" + csvc.Idcsvc + "', Donvi=N'" + csvc.Soluong + "'";

            if (processdata.Instance.ExecuteNonQuery(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        public bool xoa_csvc(CSVC_DTO csvc)
        {
            string query = "DELETE FROM t_cosovatchat WHERE ID ='" + csvc.Temp + "'";

            if (processdata.Instance.ExecuteNonQuery(query))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public bool ThemCSVC(CSVC_DTO csvc)
        {
            //kiem tra
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "SELECT Id FROM CSVC WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd.Parameters["@Id"].Value = csvc.Id;

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();
            int           count  = 0;

            if (reader.Read())
            {
                count++;
                string s = reader.GetString(0);
            }
            reader.Close();
            if (count == 1)
            {
                return(false);
            }

            SqlConnection conn1 = ConnectToSQL.HamKetNoi();
            string        str1  = "INSERT INTO CSVC(Id, Ten, Dongia, Soluong) VALUES (@Id, @Ten, @Dongia, @Soluong)";
            SqlCommand    cmd1  = new SqlCommand(str1, conn);

            cmd1.CommandType = CommandType.Text;

            cmd1.Parameters.Add("@Id", SqlDbType.NChar, 10);
            cmd1.Parameters.Add("@Ten", SqlDbType.NVarChar, 50);
            cmd1.Parameters.Add("@Dongia", SqlDbType.Float);
            cmd1.Parameters.Add("@Soluong", SqlDbType.Int);

            cmd1.Parameters["@Id"].Value      = csvc.Id;
            cmd1.Parameters["@Ten"].Value     = csvc.Ten;
            cmd1.Parameters["@Dongia"].Value  = csvc.Dongia;
            cmd1.Parameters["@Soluong"].Value = csvc.Soluong;

            conn1.Open();
            cmd1.ExecuteNonQuery();
            conn1.Close();
            return(true);
        }
Пример #10
0
        public bool XoaCSVC(CSVC_DTO csvc)
        {
            SqlConnection conn = ConnectToSQL.HamKetNoi();
            string        str  = "DELETE FROM CSVC WHERE Id = @Id";
            SqlCommand    cmd  = new SqlCommand(str, conn);

            cmd.CommandType = CommandType.Text;
            cmd.Parameters.Add("@Id", System.Data.SqlDbType.NChar, 10);
            cmd.Parameters["@Id"].Value = csvc.Id;

            conn.Open();
            int t = cmd.ExecuteNonQuery();

            if (t < 1)
            {
                return(false);
            }
            conn.Close();
            return(true);
        }
Пример #11
0
        private void btnXoaThietBi_Click(object sender, EventArgs e)
        {
            //lay du lieu tu form
            string id      = txtID.Text;
            string ten     = txtTen.Text;
            float  dongia  = float.Parse(txtDonGia.Text);
            int    soluong = int.Parse(txtSoLuong.Text);

            //thao tac xoa
            CSVC_DTO csvc = new CSVC_DTO(id, ten, dongia, soluong);
            CSVC_BUS t    = new CSVC_BUS();

            if (!t.XoaCSVC(csvc))
            {
                MessageBox.Show("Xóa không thành công. Vui lòng thử lại!");
            }

            //hien thi lai danh sach
            dgvDSThietBi.DataSource = t.LoadCSVC();
            bingding();
        }
Пример #12
0
 public bool xoavattu(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.xoa_vattu(csvc));
 }
Пример #13
0
        public bool ThemCSVC(CSVC_DTO csvc)
        {
            CSVC_DAO t = new CSVC_DAO();

            return(t.ThemCSVC(csvc));
        }
Пример #14
0
        public bool XoaCSVC(CSVC_DTO csvc)
        {
            CSVC_DAO t = new CSVC_DAO();

            return(t.XoaCSVC(csvc));
        }
Пример #15
0
        public bool CapNhatCSVC(CSVC_DTO csvc)
        {
            CSVC_DAO t = new CSVC_DAO();

            return(t.CapNhatCSVC(csvc));
        }
Пример #16
0
 public DataTable load_dgv(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.load_dgv(csvc));
 }
Пример #17
0
 public bool suacsvc(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.sua_csvc(csvc));
 }
Пример #18
0
 public bool xoacsvc(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.xoa_csvc(csvc));
 }
Пример #19
0
 public bool themcsvc(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.them_csvc(csvc));
 }
Пример #20
0
 public bool suavattu(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.sua_vattu(csvc));
 }
Пример #21
0
 public bool themvattu(CSVC_DTO csvc)
 {
     return(CSVC_DAO.Instance.them_vattu(csvc));
 }