public bool Create(Users u)
        {
            u.Password = SecurityHelper.Encrypt(u.Password);
            string sql = "INSERT INTO Users(ID, UserName, Password, IsAdmin, CreatedOn, CreatedBy, IsDeleted) VALUES(@ID, @UserName, @Password, @IsAdmin,@CreatedOn, @CreatedBy, @IsDeleted)";

            SqlParameter[] pr =
            {
                new SqlParameter("@ID",        u.ID),
                new SqlParameter("@UserName",  u.UserName),
                new SqlParameter("@Password",  u.Password),
                new SqlParameter("@IsAdmin",   u.IsAdmin),
                new SqlParameter("@CreatedOn", u.CreatedOn),
                new SqlParameter("@CreatedBy", u.CreatedBy),
                new SqlParameter("@IsDeleted", u.IsDeleted)
            };
            return(_helper.ExcuteNonQuery(sql, pr, CommandType.Text));//excutenonquery thực thi , trả về true or false( thêm xóa xửa)
        }
Example #2
0
        public bool Create(Employees e)
        {
            string sql = "Insert into Employees(FullName, BirthDay, Phone, IdentityCard, Address, Sex, Email, NgayLamViec, Note, CreatedOn, CreatedBy, IsDeleted) values (@FullName, @BirthDay, @Phone, @IdentityCard, @Address, @Sex, @Email, @NgayLamViec, @Note, @CreatedOn, @CreatedBy, @IsDeleted)";

            SqlParameter[] pr =
            {
                new SqlParameter("@FullName",     e.FullName),
                new SqlParameter("@BirthDay",     e.BirthDay),
                new SqlParameter("@Phone",        e.Phone),
                new SqlParameter("@IdentityCard", e.IdentityCard),
                new SqlParameter("@Address",      e.Address),
                new SqlParameter("@Sex",          e.Sex),
                new SqlParameter("@Email",        e.Email),
                new SqlParameter("@NgayLamViec",  e.WorkDay),
                new SqlParameter("@CreatedOn",    e.CreatedOn),
                new SqlParameter("@CreatedBy",    e.CreatedBy),
                new SqlParameter("@IsDeleted",    e.IsDeleted)
            };
            return(_helper.ExcuteNonQuery(sql, pr, CommandType.Text));
        }