Exemple #1
0
        // load Khoa
        public static List <KhoaDTO> Loadkhoa()
        {
            string truyvan = @"SELECT * FROM tbl_Khoa";

            DataTable dataTable = DataProvider.TruyVanDataReader(truyvan);

            KhoaDTO khoa;

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                List <KhoaDTO> listkhoa = new List <KhoaDTO>();
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    khoa = new KhoaDTO
                    {
                        MaKhoa  = dataTable.Rows[i]["Makhoa"].ToString(),  //1
                        TenKhoa = dataTable.Rows[i]["TenKhoa"].ToString(), //2
                    };

                    listkhoa.Add(khoa);
                }
                return(listkhoa);
            }
            return(null);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            KhoaDTO a = new KhoaDTO(textBox1.Text, textBox2.Text);

            mykhoabul.suamotkhoa(a);
            hienthi();
        }
Exemple #3
0
        public ActionResult <KhoaDTO> CreateKhoas(KhoaDTO khoaDTO)
        {
            var new_khoa = _mapper.Map <Khoa>(khoaDTO);

            _service.CreateKhoas(new_khoa);
            _service.SaveChange();

            return(Ok(new_khoa));
        }
Exemple #4
0
        public List <KhoaDTO> SearchListKhoa(string valueToSearch)
        {
            List <KhoaDTO> List      = new List <KhoaDTO>();
            string         query     = string.Format("SELECT * FROM dbo.Khoa WHERE CONCAT(MaKhoa, TenKhoa, GhiChu) LIKE N'%" + valueToSearch + "%'");
            DataTable      dataTable = DataBaseConnection.Instance.ExecuteQuery(query);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                KhoaDTO khoa = new KhoaDTO(dataRow);
                List.Add(khoa);
            }
            return(List);
        }
Exemple #5
0
        public List <KhoaDTO> GetListKhoa()
        {
            List <KhoaDTO> List      = new List <KhoaDTO>();
            string         query     = "SELECT * FROM dbo.Khoa";
            DataTable      dataTable = DataBaseConnection.Instance.ExecuteQuery(query);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                KhoaDTO khoa = new KhoaDTO(dataRow);
                List.Add(khoa);
            }
            return(List);
        }
        public void suaKhoa(KhoaDTO khoasua)
        {
            //conn = new SqlConnection(@"Data Source=DESKTOP-QSF19BO\SQLEXPRESS;Initial Catalog=QuanLySinhVienExport;Integrated Security=True");
            //conn.Open();
            setConnection();
            String     sqlsua = "update Khoa set TenKhoa=@ten where MaKhoa=@ma ";
            SqlCommand cmd    = new SqlCommand(sqlsua, conn);

            cmd.Parameters.AddWithValue("ma", khoasua.MaKhoa);
            cmd.Parameters.AddWithValue("ten", khoasua.TenKhoa);
            cmd.ExecuteNonQuery();
            //conn.Close();
            setDisconnection();
        }
        public void themKhoa(KhoaDTO khoamoi)
        {
            //conn = new SqlConnection(@"Data Source=DESKTOP-QSF19BO\SQLEXPRESS;Initial Catalog=QuanLySinhVienExport;Integrated Security=True");
            //conn.Open();
            setConnection();
            String     sqlthem = "insert into Khoa values(@ma,@ten) ";
            SqlCommand cmd     = new SqlCommand(sqlthem, conn);

            cmd.Parameters.AddWithValue("ma", khoamoi.MaKhoa);
            cmd.Parameters.AddWithValue("ten", khoamoi.TenKhoa);
            cmd.ExecuteNonQuery();
            //conn.Close();
            setDisconnection();
        }
Exemple #8
0
        public ActionResult <KhoaDTO> UpdateKhoa(string maKhoa, KhoaDTO khoaDTO)
        {
            var edit_khoa = _service.GetKhoasByMaKhoa(maKhoa);

            if (edit_khoa == null)
            {
                return(NotFound());
            }
            _mapper.Map(khoaDTO, edit_khoa);

            _service.UpdateKhoa(edit_khoa);

            _service.SaveChange();

            return(Ok());
        }
        public List <KhoaDTO> DocBangKhoa()
        {
            //conn = new SqlConnection(@"Data Source=DESKTOP-QSF19BO\SQLEXPRESS;Initial Catalog=QuanLySinhVienExport;Integrated Security=True");
            List <KhoaDTO> dsKhoa = new List <KhoaDTO>();

            //conn.Open();
            setConnection();
            SqlCommand    cmd = new SqlCommand("SELECT * FROM Khoa", conn);
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                KhoaDTO aKhoa = new KhoaDTO(dr[0].ToString(), dr["TenKhoa"].ToString());
                dsKhoa.Add(aKhoa);
            }
            //conn.Close();
            setDisconnection();
            return(dsKhoa);
        }
        public List <KhoaDTO> TimKhoa(String ma)
        {
            //conn = new SqlConnection(@"Data Source=DESKTOP-QSF19BO\SQLEXPRESS;Initial Catalog=QuanLySinhVienExport;Integrated Security=True");
            //conn.Open();
            setConnection();
            String     sqltim = "select * from khoa where MaKhoa=@ma";
            SqlCommand cmd    = new SqlCommand(sqltim, conn);

            cmd.Parameters.AddWithValue("ma", ma);
            SqlDataReader dr = cmd.ExecuteReader();

            dr.Read();
            KhoaDTO a = new KhoaDTO(dr["MaKhoa"].ToString(), dr["TenKhoa"].ToString());

            //conn.Close();
            setDisconnection();
            List <KhoaDTO> ds = new List <KhoaDTO>();

            ds.Add(a);
            return(ds);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int cout = 0;

            cout = dataGridView1.Rows.Count;// đếm tất cả các dòng trong datagridview
            String chuoi  = "";
            int    chuoi2 = 0;

            chuoi  = Convert.ToString(dataGridView1.Rows[cout - 1].Cells[0].Value);
            chuoi2 = Convert.ToInt32((chuoi.Remove(0, 4)));//bỏ đi 3 ký tự bắt đầu từ vị trí 0;
            if (chuoi2 + 1 < 10)
            {
                textBox1.Text = "KHOA000" + (chuoi2 + 1).ToString();
            }
            else if (chuoi2 + 1 >= 10 && chuoi2 + 1 < 100)
            {
                textBox1.Text = "KHOA00" + (chuoi2 + 1).ToString();
            }
            KhoaDTO a = new KhoaDTO(textBox1.Text, textBox2.Text);

            mykhoabul.themmotkhoa(a);
            hienthi();
        }
 public void suamotkhoa(KhoaDTO a)
 {
     mykhoadal.suaKhoa(a);
 }
 public void themmotkhoa(KhoaDTO a)
 {
     mykhoadal.themKhoa(a);
 }