예제 #1
0
        public bool InsertGiaoVien(GiaoVienVO gv)
        {
            try
            {
                string         query         = string.Format("insert into GiaoVien(MaGV,TenGV,DiaChi,SoDienThoai) Values(@MaGV,@TenGV,@DiaChi,@SoDienThoai)");
                SqlParameter[] sqlParameters = new SqlParameter[4];

                sqlParameters[0]       = new SqlParameter("@MaGV", SqlDbType.VarChar);
                sqlParameters[0].Value = Convert.ToString(gv.MaGV);

                sqlParameters[1]       = new SqlParameter("@TenGV", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(gv.TenGV);

                sqlParameters[2]       = new SqlParameter("@DiaChi", SqlDbType.NVarChar);
                sqlParameters[2].Value = Convert.ToString(gv.DiaChi);

                sqlParameters[3]       = new SqlParameter("@SoDienThoai", SqlDbType.VarChar);
                sqlParameters[3].Value = Convert.ToString(gv.SoDienThoai);

                return(conn.executeInsertQuery(query, sqlParameters));
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        public bool DeleteGiaoVien(GiaoVienVO gv)
        {
            try
            {
                string query = string.Format("DELETE GiaoVien Where MaGV = @MaGV and TenGV=@TenGV and DiaChi=@DiaChi and SoDienThoai=@SoDienThoai");

                SqlParameter[] sqlParameters = new SqlParameter[4];

                sqlParameters[0]       = new SqlParameter("@MaGV", SqlDbType.VarChar);
                sqlParameters[0].Value = Convert.ToString(gv.MaGV);

                sqlParameters[1]       = new SqlParameter("@TenGV", SqlDbType.NVarChar);
                sqlParameters[1].Value = Convert.ToString(gv.TenGV);

                sqlParameters[2]       = new SqlParameter("@DiaChi", SqlDbType.NVarChar);
                sqlParameters[2].Value = Convert.ToString(gv.DiaChi);

                sqlParameters[3]       = new SqlParameter("@SoDienThoai", SqlDbType.VarChar);
                sqlParameters[3].Value = Convert.ToString(gv.SoDienThoai);

                return(conn.executeInsertQuery(query, sqlParameters));
            }
            catch
            {
                return(false);
            }
        }
        public bool themGiaoVienTheoTen(GiaoVienVO gV)
        {
            String[] ma = gV.TenGV.Split(' ');
            int      i  = ma.Count();

            gV.MaGV = ma[i - 1].ToLower();
            return(_GiaoVienDAO.InsertGiaoVienTheoTen(gV));
        }
        public bool themGiaoVien(GiaoVienVO gV)
        {
            bool a = _GiaoVienDAO.InsertGiaoVien(gV);

            if (a == true)
            {
                return(true);
            }
            return(false);
        }
예제 #5
0
        public DataTable getGiaoVienByName(GiaoVienVO gv)
        {
            string query = string.Format("select * from GiaoVien where TenGV = @TenGV");

            SqlParameter[] sqlParameters = new SqlParameter[1];

            sqlParameters[0]       = new SqlParameter("@TenGV", SqlDbType.NVarChar);
            sqlParameters[0].Value = Convert.ToString(gv.TenGV);

            return(conn.executeSelectQuery(query, sqlParameters));
        }
        public GiaoVienVO getGiaoVienByName(GiaoVienVO gv)
        {
            GiaoVienVO giaoVienVO = new GiaoVienVO();
            DataTable  dataTable  = new DataTable();

            dataTable = _GiaoVienDAO.getGiaoVienByName(gv);
            if (dataTable != null)
            {
                foreach (DataRow dr in dataTable.Rows)
                {
                    giaoVienVO.MaGV  = dr[0].ToString();
                    giaoVienVO.TenGV = dr[1].ToString();
                }
            }

            return(giaoVienVO);
        }
예제 #7
0
        private void importExelToSQL(DataTable dt)
        {
            if (dt != null)
            {
                for (int i = 3; i < dt.Rows.Count; i++)
                {
                    for (int j = 3; j < dt.Columns.Count; j++)
                    {
                        string str = dt.Rows[i].ItemArray[j].ToString();
                        if (str != "")
                        {
                            if (str != " " || str != "\n" || str != " " || str != "  ")
                            {
                                String[] mang = str.Split('(');

                                String[] ten    = mang[0].Split('-');
                                string   tenGV  = ten[0];
                                string   tenMH  = ten[1];
                                string   tenLop = ten[2];

                                string tiet = mang[1].Split(')')[0];

                                GiaoVienVO GV = new GiaoVienVO();
                                MonHocVO   MH = new MonHocVO();
                                LopVO      LH = new LopVO();
                                //lay ma GV thong qua TenGV
                                GV.TenGV = tenGV;
                                //tao maGV dua vao ten
                                //GV.TenGV=tenGV.Split(' ')o
                                GiaoVienVO gv = giaoVienBUS.getGiaoVienByName(GV);


                                //lay maMH thong qua TenMH

                                MH.TenMonHoc = tenMH;
                                MonHocVO mh = monHocBUS.getMonHocByName(MH);

                                //Lay MaLop Thong Qua Ten
                                LH.TenLop = tenLop;
                                LopVO lh = lopHocBUS.getLopHocByName(LH);

                                LichDayVO LD = new LichDayVO();
                                LD.MaGV  = gv.MaGV;
                                LD.MaMH  = mh.MaMH;
                                LD.MaLop = lh.MaLop;
                                LD.Thu   = j - 1 + "";
                                LD.Tiet  = tiet;

                                //cat chuoi lay tuan
                                string chuoi          = dt.Rows[2].ItemArray[0].ToString();
                                string layChuoiCoTuan = (chuoi.Split('\n')[0]).Trim();
                                string tuanDangString = (layChuoiCoTuan.Split(' ')[1]).Trim();
                                int    tuan           = Convert.ToInt32(tuanDangString);
                                LD.Tuan = tuan;
                                lapLichBUS.themLapLichBoPhong(LD);
                                //LD.MaPhong = "P001"; ->khoi truyen
                                //if (lapLichBUS.themLapLichBoPhong(LD))
                                //    MessageBox.Show("Da Them Vao CSDL");
                                //else
                                //    MessageBox.Show("ko them vao CSDL duoc");
                            }
                        }
                    }
                }
            }
        }
 public bool XoaGiaoVien(GiaoVienVO gV)
 {
     return(_GiaoVienDAO.DeleteGiaoVien(gV));
 }
 public bool CapNhatGiaoVien(GiaoVienVO gV)
 {
     return(_GiaoVienDAO.UpdateGiaoVien(gV));
 }