Beispiel #1
0
        public long Insert(CanboEntity canbo)
        {
            cnn.Open();

            using (SqlCommand cmd = new SqlCommand("spInsertCanbo", cnn))
            {
                //  @sTenCanbo , --sTenCanbo - nvarchar(100)
                // @sTenTaikhoan , --sTenTaikhoan - nvarchar(50)
                // @sMatkhau , --sMatkhau - varchar(50)
                // @sSodienthoai, --sSodienthoai - char(10)
                // @sEmail , --sEmail - varchar(150)
                //@tNgaysinh , --tNgaysinh - date
                // @bGioitinh, --bGioitinh - bit
                //@sCMND , --sCMND - char(12)
                // @sDiachi -
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@sTenCanbo", canbo.STenCanbo);
                cmd.Parameters.AddWithValue("@sSodienthoai", canbo.SSodienthoai);
                cmd.Parameters.AddWithValue("@sEmail", canbo.SEmail);
                cmd.Parameters.AddWithValue("@tNgaysinh", canbo.TNgaySinh);
                cmd.Parameters.AddWithValue("@bGioitinh", canbo.BGioiTinh);
                cmd.Parameters.AddWithValue("@sCMND", canbo.SCMND);
                cmd.Parameters.AddWithValue("@sDiachi", canbo.SDiaChi);
                cmd.Parameters.AddWithValue("@sTenTaikhoan", canbo.STenTaikhoan);
                cmd.Parameters.AddWithValue("@sMatkhau", canbo.SMatkhau);
                Object iMacabo = cmd.ExecuteScalar();
                return(Convert.ToInt64(iMacabo));
            }
        }
Beispiel #2
0
        public List <CanboEntity> CanboGetByPK(long canboID)
        {
            List <CanboEntity> glstCabo = new List <CanboEntity>();

            cnn.Open();
            using (SqlCommand cmd = new SqlCommand("spGetCanboByPK_iCanboID", cnn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@canbID", canboID);
                SqlDataReader dar = cmd.ExecuteReader();
                if (dar.HasRows)
                {
                    while (dar.Read())
                    {
                        CanboEntity canbo = new CanboEntity();
                        canbo.PK_iCanboID  = Convert.ToInt64(dar["PK_iCanboID"]);
                        canbo.STenCanbo    = dar["sTenCanbo"].ToString();
                        canbo.SSodienthoai = dar["sSodienthoai"].ToString();
                        canbo.SEmail       = dar["sEmail"].ToString();
                        canbo.TNgaySinh    = DateTime.Parse(dar["tNgaysinh"].ToString());
                        canbo.BGioiTinh    = Boolean.Parse(dar["bGioitinh"].ToString());
                        canbo.STenTaikhoan = dar["sTenTaikhoan"].ToString();
                        canbo.SMatkhau     = dar["sMatkhau"].ToString();
                        canbo.SCMND        = dar["sCMND"].ToString();
                        canbo.SDiaChi      = dar["sDiachi"].ToString();
                        glstCabo.Add(canbo);
                    }
                }
                cnn.Close();
                return(glstCabo);
            }
        }
Beispiel #3
0
        public long themCanbo(string tenCanbo, string sodienthoai, string email, DateTime Ngaysinh, bool gioitinh, string CMND, string taikhoan, string matkhau, string diachi)
        {
            CanboEntity canbo = new CanboEntity();

            canbo.STenCanbo    = tenCanbo;
            canbo.SSodienthoai = sodienthoai;
            canbo.SEmail       = email;
            canbo.TNgaySinh    = Ngaysinh;
            canbo.BGioiTinh    = gioitinh;
            canbo.SCMND        = CMND;
            canbo.SDiaChi      = diachi;
            canbo.SMatkhau     = matkhau;
            canbo.STenTaikhoan = taikhoan;
            return(new CanboDAL().Insert(canbo));
        }
Beispiel #4
0
        public bool suaCanbo(CanboEntity canbo)
        {
            cnn.Open();

            using (SqlCommand cmd = new SqlCommand("spUpdateCanbo", cnn))
            {
                //  @sTenCanbo , --sTenCanbo - nvarchar(100)
                // @sTenTaikhoan , --sTenTaikhoan - nvarchar(50)
                // @sMatkhau , --sMatkhau - varchar(50)
                // @sSodienthoai, --sSodienthoai - char(10)
                // @sEmail , --sEmail - varchar(150)
                //@tNgaysinh , --tNgaysinh - date
                // @bGioitinh, --bGioitinh - bit
                //@sCMND , --sCMND - char(12)
                // @sDiachi -
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@PK_iCanboID", canbo.PK_iCanboID);
                cmd.Parameters.AddWithValue("@sTenCanbo", canbo.STenCanbo);
                cmd.Parameters.AddWithValue("@sSodienthoai", canbo.SSodienthoai);
                cmd.Parameters.AddWithValue("@sEmail", canbo.SEmail);
                cmd.Parameters.AddWithValue("@tNgaysinh", canbo.TNgaySinh);
                cmd.Parameters.AddWithValue("@bGioitinh", canbo.BGioiTinh);
                cmd.Parameters.AddWithValue("@sCMND", canbo.SCMND);
                cmd.Parameters.AddWithValue("@sDiachi", canbo.SDiaChi);
                cmd.Parameters.AddWithValue("@sTenTaikhoan", canbo.STenTaikhoan);
                cmd.Parameters.AddWithValue("@sMatkhau", canbo.SMatkhau);
                long i = cmd.ExecuteNonQuery();
                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #5
0
        public List <CanboEntity> GetCanbo(long chucvuID)
        {
            List <CanboEntity> glstCanboBophan = new List <CanboEntity>();

            cnn.Open();
            using (SqlCommand cmd = new SqlCommand("spGetCanboByFK_iChucvu", cnn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@chucvuID", chucvuID);
                SqlDataReader dar = cmd.ExecuteReader();
                if (dar.HasRows)
                {
                    while (dar.Read())
                    {
                        CanboEntity canbo = new CanboEntity();
                        canbo.PK_iCanboID = Convert.ToInt64(dar["PK_iCanboID"]);
                        canbo.STenCanbo   = dar["sTenCanbo"].ToString();
                        glstCanboBophan.Add(canbo);
                    }
                }
                cnn.Close();
                return(glstCanboBophan);
            }
        }